node.js npm 安装错误代码 128
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35021692/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
npm install error code 128
提问by andy mccullough
I am receiving the following error when trying to run npm installafter a fresh install of Node and Git
npm install在全新安装 Node 和 Git 后尝试运行时收到以下错误
Anyone have any idea what could be causing it, and what to do to fix it?
任何人都知道可能导致它的原因,以及如何解决它?
package.json(removed company details)
package.json(已删除公司详细信息)
{
"name": "xxx",
"version": "1.0.0",
"description": "xxx",
"engines": {
"node": "5.0.0",
"npm": "3.3.9"
},
"repository": "xxx",
"private": true,
"license": "UNLICENSED",
"dependencies": {
"dijit": "https://github.com/dojo/dijit.git#1.10.4",
"dojo": "1.10.4",
"fg-dialog": "0.1.5",
"politespace": "0.1.4",
"shoestring": "1.0.3"
},
"devDependencies": {
"body-parser": "^1.14.1",
"chalk": "^1.1.1",
"compression": "^1.6.0",
"del": "^2.0.2",
"dojo-util": "https://github.com/dojo/util.git#1.10.4",
"express": "^4.13.3",
"glob": "^5.0.15",
"gulp": "^3.9.0",
"gulp-concat": "^2.6.0",
"gulp-git": "^1.6.0",
"gulp-html-minifier": "^0.1.6",
"gulp-jsbeautifier": "^1.0.1",
"gulp-jshint": "^1.11.2",
"gulp-jshint-xml-file-reporter": "^0.5.1",
"gulp-jsonminify": "^1.0.0",
"gulp-replace": "^0.5.4",
"gulp-task-listing": "^1.0.1",
"gulp-uglify": "^1.4.1",
"gulp-util": "^3.0.6",
"gulp-zip": "^3.0.2",
"intern": "https://github.com/theintern/intern.git",
"jshint-stylish": "^2.0.1",
"merge-stream": "^1.0.0",
"minimist": "^1.2.0",
"open": "^0.0.5",
"q": "^1.4.1",
"request": "^2.65.0",
"require-dir": "^0.3.0",
"run-sequence": "^1.1.2",
"selenium-standalone": "^4.6.3"
},
"scripts": {
"postinstall": "gulp install"
}
}
回答by Mark Stosberg
A recommended first step is to use the latest npm:
推荐的第一步是使用最新的 npm:
npm install -g npm
(You may need sudo). You are using npm 2.x, the latest is 3.5.x.
(您可能需要sudo)。您使用的是 npm 2.x,最新的是 3.5.x。
回答by Archdoog
In my case I had just upgraded npm and package-lock.json was trying to install one of the project's packages from an unavailable git commit version.
就我而言,我刚刚升级了 npm 并且 package-lock.json 试图从不可用的 git commit 版本安装项目的包之一。
Deleting and letting npm re-create the file package-lock.json resolved the issue.
删除并让 npm 重新创建文件 package-lock.json 解决了该问题。
rm package-lock.json
Note:It looks like package-lock.json maintains more details about the node_modules tree, so in a complicated/version specific project it may be important to isolate the specific line(s) causing the issue, versus just delete the package-lock.json file.
注意:看起来 package-lock.json 维护了更多关于 node_modules 树的细节,所以在一个复杂/版本特定的项目中,隔离导致问题的特定行可能很重要,而不是仅仅删除包锁。 .json 文件。
回答by u6109292
Firstly, I deleted the npmand npm-cachedirectories that locate in c:\myUser\AppData\Roaming.
Then, I excuted npm install -g npm. That resolved my problem.
首先,我删除了npm,并npm-cache在找到的目录c:\myUser\AppData\Roaming。然后,我执行了npm install -g npm。那解决了我的问题。
回答by Zoro-Alforque
The error points at revisioning, specifically usage of 1.10.4. Check that the BitBucket repos for dijit.git and util.git are setup with tagging. More information on versioning/tagging at Atlassian: https://confluence.atlassian.com/bitbucket/use-repo-tags-321860179.html.
错误指向修订,特别是 1.10.4 的使用。检查 dijit.git 和 util.git 的 BitBucket 存储库是否设置了标记。有关 Atlassian 版本控制/标记的更多信息:https: //confluence.atlassian.com/bitbucket/use-repo-tags-321860179.html。
If you're using SSH with a saved password, the references to your personal repositories will need to connect via SSH using the format below.
如果您使用 SSH 并保存了密码,则需要使用以下格式通过 SSH 连接对您个人存储库的引用。
git+ssh://[email protected]/{user}/{repository}.git
回答by The Coder
I had the same npm error code 128 but it also had a reference to the debug.log file in the npm-cache which revealed the real problem.
我有相同的 npm 错误代码 128,但它也引用了 npm-cache 中的 debug.log 文件,这揭示了真正的问题。
Two of the dependencies in the package.json were pointing to private repositories directly that I don't have access to.
package.json 中的两个依赖项直接指向我无权访问的私有存储库。
Once I fixed that (details here) I was able to run npm install successfully. Note: no reinstall or update of npm required!
一旦我解决了这个问题(详细信息在这里),我就能够成功运行 npm install 。注意:不需要重新安装或更新 npm!
回答by Zakaria.dem
you must use cmd as adminstrator in windows, or add sudo in linux
必须在windows下使用cmd作为adminstrator,或者在linux下添加sudo
回答by Hasangi
Remove the node_modulesfolder and delete package-lock.jsonfile. Then run following commands,
删除node_modules文件夹并删除package-lock.json文件。然后运行以下命令,
npm cache clean --force
npm install
npm 缓存清理 --force
安装
回答by NoNaMe
I was also getting the same error on windows 10 and I fixed it by adding the ssh key again in the GitHub by generating using the following URL: https://help.github.com/enterprise/2.13/user/articles/connecting-to-github-with-ssh/
我在 Windows 10 上也遇到了同样的错误,我通过使用以下 URL 生成再次在 GitHub 中添加 ssh 密钥来修复它:https: //help.github.com/enterprise/2.13/user/articles/connecting-到-github-with-ssh/
to check the Existing key use following commands:
使用以下命令检查现有密钥:
- Open Git Bash. press the windows button and search for Git Bash.
- Enter
ls -al ~/.sshto see if existing SSH keys are present - Check the directory listing to see if you already have a public SSH key.
if key files exist it will list them(using default file name) like :
- id_dsa.pub
- id_ecdsa.pub
- id_ed25519.pub
- id_rsa.pub
- 打开 Git Bash。按 windows 按钮并搜索 Git Bash。
- 输入
ls -al ~/.ssh以查看现有的 SSH 密钥是否存在 - 检查目录列表以查看您是否已经拥有公共 SSH 密钥。如果存在密钥文件,它将列出它们(使用默认文件名),例如:
- id_dsa.pub
- id_ecdsa.pub
- id_ed25519.pub
- id_rsa.pub
After that, you have to make sure that ssh-agent is running you can use eval $(ssh-agent -s) command to run the ssh-agent
之后,您必须确保 ssh-agent 正在运行,您可以使用 eval $(ssh-agent -s) 命令来运行 ssh-agent
After this, you have to add this existing key using the command: ssh-add ~/.ssh/id_rsa
在此之后,您必须使用以下命令添加此现有密钥: ssh-add ~/.ssh/id_rsa
now as you file is added you can get key to the clipboard using command clip < ~/.ssh/id_rsa.pub
现在,当您添加文件时,您可以使用命令获取剪贴板的密钥 clip < ~/.ssh/id_rsa.pub
go to GitHub site and click on settings in top right corner and add this ssh key to gitHub.
转到 GitHub 站点并单击右上角的设置并将此 ssh 密钥添加到 gitHub。
restart the command prompt and error will be fixed.
重新启动命令提示符,错误将被修复。
hope this will help someone.
希望这会帮助某人。


