[英]node module not found .MODULE NOT FOUND
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我试图让节点代码基本上工作 node app.js
Look into your project directory where you initialized node app.js
.查看初始化
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
. Go 进入项目目录并启动你的
node app.js
。
90% sure, hopefully this will fix it. 90% 肯定,希望这会解决它。
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.在这里,您位于
C:\Program Files\nodejs\node_modules\npm
并且您正在尝试运行存储在计算机其他位置的文件App.js
I'd recommend going through these simple steps to fix the problem: (let's say you want Node
to run your file App.js
.我建议通过这些简单的步骤来解决问题:(假设您希望
Node
运行您的文件App.js
。
ls
(bash, shell, powershell) or dir
(cmd). ls
(bash、shell、powershell)或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
.如果您的文件 (
App.js
) 在上述命令的 output 中列出,请检查拼写并确保大小写与您提供给node
的内容完全匹配。 That is you command must be node App
or node App.js
and not node app.js
or node aPP.js
...那就是你的命令必须是
node App
或node App.js
而不是node app.js
或node aPP.js
...
If your file isn't listed (what is the more probable outcome) then go to step 2
.如果您的文件未列出(更可能的结果是什么),则 go 到
step 2
。
App.js
) from your file explorer.App.js
) 的文件夹的完整路径。cd copied_path
. cd copied_path
。node App.js
node App.js
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.