【发布时间】:2022-07-22 11:45:55
【问题描述】:
我的 npm 运行良好,但是今天它显示错误提示,
错误:找不到模块“C:\Users\mrsim\node_modules\npm\bin\npm-cli.js”
我的 npm 在一小时前运行良好。我在 VSCode 中输入了“npm start”来启动我的 react-app,它运行得非常好!
当我创建服务器文件夹并输入“npm install express”时,这场噩梦就开始了。
通常当我在终端输入“npm install express”时,它会自动为我创建 node-modules 文件夹和 package.json 没有任何问题,但这些都没有出现。
为了解决这个问题,我先修复了节点,没有成功。
接下来我更改了我的环境变量,但没有奏效。
接下来我使用 "SET PATH=C:\Program Files\Nodejs;%PATH%" 这句话在终端里,没用。
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module 'C:\Users\mrsim\node_modules\npm\bin\npm-cli.js'
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module 'C:\Users\mrsim\node_modules\npm\bin\npm-cli.js'
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
这是终端上出现的错误信息。如果我去那个目录,我找不到 npm.cli.js
我该怎么办...?
【问题讨论】:
-
任何 npm 命令返回相同的错误?你试过卸载快递吗?
-
每次我在终端输入任何 npm 命令,总是会出现同样的错误。这就是为什么我不能卸载 express,因为它也是 npm 命令
-
我删除了,重新安装了node,还是不行,出现同样的错误。
-
您是否尝试过删除您家 (C:\Users\mrsim\node_modules) 中的那个 node_modules 目录?
-
感谢您的建议!我会试试看:)祝你有美好的一天!