node app.js
node:internal/modules/cjs/loader:998
throw err;
^
Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\app.js'
at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
at Module._load (node:internal/modules/cjs/loader:841:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
i was trying to get the node code to work basically node app.js
Look into your project directory where you initialized node app.js
. The issue is that you're not in the project directory where this file exists. Go into the project directory and launch your node app.js
.
90% sure, hopefully this will fix it.
This error usually occurs when you're not in the right folder. Here you're in C:\Program Files\nodejs\node_modules\npm
and you're trying to run your file App.js
which is stored elsewhere on your computer.
I'd recommend going through these simple steps to fix the problem: (let's say you want Node
to run your file App.js
.
ls
(bash, shell, powershell) or dir
(cmd). If your file ( App.js
) is listed on the output of the above command, then check the spelling and make sure the case exactly matches what you provided to node
. That is you command must be node App
or node App.js
and not node app.js
or node aPP.js
...
If your file isn't listed (what is the more probable outcome) then go to step 2
.
App.js
) from your file explorer.cd copied_path
. node App.js
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.