werthan
werthan•2mo ago

Deno Compile Can't Find Node Module

{
"version": "0.0.1",
"imports": {
"@aws-sdk/client-ssm": "npm:@aws-sdk/client-ssm@^3.750.0",
"@cliffy/command": "jsr:@cliffy/command@^1.0.0-rc.7",
"@std/cli": "jsr:@std/cli@^1.0.13",
"@std/yaml": "jsr:@std/yaml@^1.0.5"
}
}
{
"version": "0.0.1",
"imports": {
"@aws-sdk/client-ssm": "npm:@aws-sdk/client-ssm@^3.750.0",
"@cliffy/command": "jsr:@cliffy/command@^1.0.0-rc.7",
"@std/cli": "jsr:@std/cli@^1.0.13",
"@std/yaml": "jsr:@std/yaml@^1.0.5"
}
}
Cannot find module 'file:///var/folders/55/bwth_1_x1pd93fcj6nn3wyrm0000gr/T/deno-compile-cloudenvt-ts/.deno_compile_node_modules/localhost/@aws-sdk/client-ssm/3.750.0/index.js'
Cannot find module 'file:///var/folders/55/bwth_1_x1pd93fcj6nn3wyrm0000gr/T/deno-compile-cloudenvt-ts/.deno_compile_node_modules/localhost/@aws-sdk/client-ssm/3.750.0/index.js'
Running deno compile on a ts file that includes another file that includes the aws sdk ssm client and I get the above error when I try to run the binary.
6 Replies
werthan
werthanOP•2mo ago
Maybe just noob stuff at work here. If I add "nodeModulesDir": "auto" to the deno.json it seems to work.
Mrcool 🇵🇸
Maybe try to use --include flag , I think if the file is a dynamic import that's not statically analyzable it can't include it automatically
Landerfine l'écarlate
deno ./test_\src\test\easy.ts --include
deno ./test_\src\test\easy.ts --include
{
"workspace":["./core", "./meta", "./schema", "./shell", "./test_"],
"nodeModulesDir":"auto",
"imports": {
"@zxcvbn-ts/core": "npm:@zxcvbn-ts/core@^3.0.4",
"@zxcvbn-ts/language-common": "npm:@zxcvbn-ts/language-common@^3.0.4",
"@zxcvbn-ts/language-en": "npm:@zxcvbn-ts/language-en@^3.0.2",
"fast-fuzzy": "npm:fast-fuzzy@^1.12.0",
"node-interval-tree": "npm:node-interval-tree@^2.1.2",
"randexp": "npm:randexp@^0.5.3",
"@donedeal0/superdiff": "npm:@donedeal0/superdiff@^3.1.2",
"@types/lodash": "npm:@types/lodash@^4.17.16",
"@types/luxon": "npm:@types/luxon@^3.4.2",

"deepdash": "npm:deepdash@^5.3.9",
"lodash": "npm:lodash@^4.17.21",
"luxon": "npm:luxon@^3.5.0",
"typescript": "npm:typescript@^5.8.2",
"zod": "npm:zod@^3.24.2"
}
}
{
"workspace":["./core", "./meta", "./schema", "./shell", "./test_"],
"nodeModulesDir":"auto",
"imports": {
"@zxcvbn-ts/core": "npm:@zxcvbn-ts/core@^3.0.4",
"@zxcvbn-ts/language-common": "npm:@zxcvbn-ts/language-common@^3.0.4",
"@zxcvbn-ts/language-en": "npm:@zxcvbn-ts/language-en@^3.0.2",
"fast-fuzzy": "npm:fast-fuzzy@^1.12.0",
"node-interval-tree": "npm:node-interval-tree@^2.1.2",
"randexp": "npm:randexp@^0.5.3",
"@donedeal0/superdiff": "npm:@donedeal0/superdiff@^3.1.2",
"@types/lodash": "npm:@types/lodash@^4.17.16",
"@types/luxon": "npm:@types/luxon@^3.4.2",

"deepdash": "npm:deepdash@^5.3.9",
"lodash": "npm:lodash@^4.17.21",
"luxon": "npm:luxon@^3.5.0",
"typescript": "npm:typescript@^5.8.2",
"zod": "npm:zod@^3.24.2"
}
}
; in the file
import { eq } from "lodash";
import { eq } from "lodash";
cause
error: Uncaught SyntaxError: The requested module 'lodash' does not provide an export named 'eq'
import { eq } from "lodash";
^
at <anonymous> (file:///D:/WORKBRENCH/TS/LIB_TS/DENO/king_ts/test_/src/utils/test.ts:3:10)
error: Uncaught SyntaxError: The requested module 'lodash' does not provide an export named 'eq'
import { eq } from "lodash";
^
at <anonymous> (file:///D:/WORKBRENCH/TS/LIB_TS/DENO/king_ts/test_/src/utils/test.ts:3:10)
any ideas ?
Mrcool 🇵🇸
1st issue, the compiled executale can't find a file you can try to include it deno compile --include node_modules/@aws-sdk myfile.ts 2nd issue deno is correct lodash doens't export eq on that version you can check with
import * as ld from "npm:lodash@^4.17.21";
console.log(ld);
import * as ld from "npm:lodash@^4.17.21";
console.log(ld);
Landerfine l'écarlate
- https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L11252 it should be here : / with deno v2.2.2/v2.2.3 I will try some stuff :cookie_deno:
GitHub
lodash/lodash.js at 4.17.21 · lodash/lodash
A modern JavaScript utility library delivering modularity, performance, & extras. - lodash/lodash
Mrcool 🇵🇸
ah yes, this does work
import ld from "npm:lodash@^4.17.21";
console.log(ld.eq);
import ld from "npm:lodash@^4.17.21";
console.log(ld.eq);

Did you find this page helpful?