如何修复这个错误-npm

9

我尝试安装npm,但出现了以下错误。 我已经卸载了npm并重新安装了它,但我仍然遇到了以下错误:


npm ERR! Linux 4.15.0-30-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "start"
npm ERR! node v8.10.0
npm ERR! npm  v3.5.2
npm ERR! code ELIFECYCLE
npm ERR! vx-leave-system@0.0.1 start: `node ./tools/server.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the vx-leave-system@0.0.1 start script 'node ./tools/server.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the vx-leave-system package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node ./tools/server.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs vx-leave-system
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls vx-leave-system
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR!     /home/seelan/Documents/vx-leave-system/npm-debug.log

我该如何修复这个问题?


问题可能是Node.js版本不匹配。 您能否发布一下您在“npm-debug.log”中的内容? 还有您所拥有的“package.json”文件。 - in need of help
6个回答

18

在Ubuntu 18.04上,以下步骤帮助我解决了问题

要删除发行版稳定版本,请执行以下操作:

sudo apt remove nodejs

这个命令将会卸载软件包并保留配置文件。

sudo apt purge nodejs

最后一步,您可以删除与已删除软件包自动安装的任何未使用软件包:

sudo apt autoremove

通过输入以下命令刷新本地软件包索引:

sudo apt update

通过运行以下命令启用NodeSource存储库

(可选) 如果您需要安装另一个版本,例如14.x,请将setup_12.x更改为setup_14.x

curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -

启用NodeSource存储库后,通过输入以下命令来安装Node.js和npm:

sudo apt install nodejs

打印版本以验证 Node.js 和 npm 是否成功安装:

node --version (v12.18.4)
npm --version (6.14.6)

5

在我看来,您正在运行较新版本的Node,但使用过时版本的NPM。

您可以执行以下任一操作:

  1. 尝试最新稳定版的NPM
    您可以使用以下命令升级到最新版本的npm:npm install -g npm@latest

  1. 彻底从计算机中卸载Node,前往它们的网站并安装最新的稳定版Node。 NPM 将随之安装。

2
我今天也遇到了这个问题,原因是我升级了node和npm版本。我猜测我的项目依赖仍在旧版本的node和npm上运行。 通过删除node_modules文件夹并运行下面的命令,问题得以解决。
npm install

我希望您能从中受益。

0

这似乎是您主目录中的权限问题。要重新拥有 .npm 目录的所有权,请执行:

sudo chown -R $(whoami) ~/.npm

0

检查依赖项的更新

npm outdate

运行下一个命令以更新依赖项

npm update

-1

删除路径文件夹目录 C:\Users\ACER\AppData\Local**\npm-cache_logs\2021-12-29T13_41_22_984Z-debug-0.log**

然后在您的CLI中运行此命令 npm install -g npm@latest

这将与您一起工作


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接