deno icon indicating copy to clipboard operation
deno copied to clipboard

Deno compile ERR_MODULE_NOT_FOUND

Open Stromberg opened this issue 1 year ago • 3 comments

Version: Deno 2.0.0

I created a script with

import pl from "npm:[email protected]";

and it runs with

deno run

(on Windows) but when I use

deno compile

and then try to run the compiled exe it complains

error: [ERR_MODULE_NOT_FOUND] Cannot find module '/node_modules/localhost/nodejs-polars/0.16.0/index.js'

Stromberg avatar Oct 14 '24 13:10 Stromberg

Can you provide a reproducible reproduction so we can reproduce this? On Windows I get:

> .\scratch.exe       
✅ Granted ffi access to "C:\Users\david\AppData\Local\Temp\deno-compile-scratch.exe\node_modules\localhost\nodejs-polars-win32-x64-msvc\0.16.0\nodejs-polars.win32-x64-msvc.node".                                                                                                  
error: Uncaught (in promise) TypeError: LoadLibraryExW failed                                                                                                                                                                                                                        
    at Object.Module._extensions..node (node:module:797:20)                                                                                                                                                                                                                          
    at Module.load (node:module:665:32)                                                                                                                                                                                                                                              
    at Function.Module._load (node:module:537:12)
    at Module.require (node:module:684:19)
    at require (node:module:808:16)
    at Object.<anonymous> (file:///C:/Users/david/AppData/Local/Temp/deno-compile-scratch.exe/node_modules/localhost/nodejs-polars/0.16.0/bin/native-polars.js:68:41)
    at Object.<anonymous> (file:///C:/Users/david/AppData/Local/Temp/deno-compile-scratch.exe/node_modules/localhost/nodejs-polars/0.16.0/bin/native-polars.js:249:4)
    at Module._compile (node:module:748:34)
    at Object.Module._extensions..js (node:module:767:10)
    at Module.load (node:module:665:32)

...because Node API currently isn't supported in deno compile. The issue for that is here: https://github.com/denoland/deno/issues/24614

dsherret avatar Oct 14 '24 19:10 dsherret

We had the same issue (#26155) , it's trying to verify if the import in commented Jsdocs exist or not, so I raised this bug (#26233), then I found that we may use the --no-check flag, which helps fix the issue in compile.

yazan-abdalrahman avatar Oct 15 '24 08:10 yazan-abdalrahman

@dsherret there was a same issue from last week #26093 but it's closed somehow

tried with deno version 2.0.1:

import chalk from "npm:[email protected]";
console.log(chalk.blue("Hello, world!"));

the script is runnable, but running the compiled executable throws ERR_MODULE_NOT_FOUND error:

$ deno --version
deno 2.0.1 (stable, release, x86_64-unknown-linux-gnu)
v8 12.9.202.13-rusty
typescript 5.6.2

$ deno run -A main.ts
Hello, world!

$ deno compile -A main.ts 
Check file:///tmp/test/main.ts
Compile file:///tmp/test/main.ts to test

$ ./test
error: [ERR_MODULE_NOT_FOUND] Cannot find module 'file:///tmp/deno-compile-test/node_modules/localhost/chalk/5.3.0/index.js' imported from 'file:///tmp/deno-compile-test/test/main.ts'

imfing avatar Oct 18 '24 23:10 imfing

Tried on linux and I get a similar .node error. Going to close as a duplicate of https://github.com/denoland/deno/issues/24614

dsherret avatar Mar 21 '25 19:03 dsherret