Closed vipcxj closed 1 year ago
can you share full log
@preveen-stack
root@8f62ca3455ff:~# node test_p.js
node:internal/modules/cjs/loader:1051
throw err;
^
Error: Cannot find module '/root/test_p.js'
at Module._resolveFilename (node:internal/modules/cjs/loader:1048:15)
at Module._load (node:internal/modules/cjs/loader:901:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
at node:internal/main/run_main_module:23:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
Node.js v20.5.1
I run it in the docker container
docker run -u root -ti -v test_p.js:/root/test_p.js node:latest bash
cd /root
node test_p.js
docker run -u root -ti -v node:latest bash
cd /root
node test_p.js
can you try the above and check
@preveen-stack I found the problem
docker run -u root -ti -v $(pwd)/test_p.js:/root/test_p.js node:latest bash
works now.
Thank you.
Details
Unable to run a super simple script using docker, It just say MODULE_NOT_FOUND. It seems that the node force to treat my simple script as a cjs module. But it isn't. I have search on google, however, all results are related to missing modules. I just want to know why node can't run such a simple plain js script.
Node.js version
v20.5.1
Example code
for (const a of process.argv) { console.log(a) }
Operating system
ubuntu
Scope
runtime
Module and version
Not applicable.