denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
97.17k stars 5.37k forks source link

Deno compile ERR_MODULE_NOT_FOUND #26238

Open Stromberg opened 2 weeks ago

Stromberg commented 2 weeks ago

Version: Deno 2.0.0

I created a script with

import pl from "npm:nodejs-polars@0.16.0";

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'
dsherret commented 2 weeks ago

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

yazan-abdalrahman commented 2 weeks ago

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.

imfing commented 1 week ago

@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:chalk@5.3.0";
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'