npm install error code 128
Asked Answered
W

14

32

I am receiving the following error when trying to run npm install after a fresh install of Node and Git

enter image description here

Anyone have any idea what could be causing it, and what to do to fix it?

package.json (removed company details)

{
    "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"
    }
}
Wilbert answered 26/1, 2016 at 18:58 Comment(0)
T
31

A recommended first step is to use the latest npm:

npm install -g npm 

(You may need sudo). You are using npm 2.x, the latest is 3.5.x.

Talbot answered 26/1, 2016 at 19:19 Comment(4)
I upgraded to Node v.5 (and in turn npm v.3) and this solved the issue. I had to manually delete the npm and npm-cache directories that were hanging around in c:\myUser\AppData\Roaming too, thanks!Wilbert
I can't explain it but this fixed my issue. I tried clearing cache, blowing away node_modules dir, etc but none of that worked.Fretful
did npm install -g npm and also with sudo but no helpVarix
now, npm only not working. module not found errorMilan
G
8

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.

Deleting and letting npm re-create the file package-lock.json resolved the issue.

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.

https://docs.npmjs.com/files/package-lock.json

Glaab answered 21/12, 2017 at 15:31 Comment(0)
F
6

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.

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.

git+ssh://[email protected]/{user}/{repository}.git
Fecund answered 7/12, 2016 at 16:30 Comment(0)
G
6

Remove the node_modules folder and delete package-lock.json file. Then run following commands,

npm cache clean --force

npm install

Greysun answered 23/4, 2018 at 8:53 Comment(0)
P
4

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.

Two of the dependencies in the package.json were pointing to private repositories directly that I don't have access to.

Once I fixed that (details here) I was able to run npm install successfully. Note: no reinstall or update of npm required!

Phosphorate answered 27/6, 2017 at 23:22 Comment(1)
Worked for me as well after giving git access to the private repo.Croaky
B
3

Firstly, I deleted the npm and npm-cache directories that locate in c:\myUser\AppData\Roaming. Then, I excuted npm install -g npm. That resolved my problem.

Boondocks answered 24/3, 2016 at 12:11 Comment(2)
for Mac users maybe: #11178454Varix
Worked for me! Thanks for saving my day.Matthew
A
3

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/

to check the Existing key use following commands:

  1. Open Git Bash. press the windows button and search for Git Bash.
  2. Enter ls -al ~/.ssh to see if existing SSH keys are present
  3. 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

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

After this, you have to add this existing key using the command: 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

go to GitHub site and click on settings in top right corner and add this ssh key to gitHub.

restart the command prompt and error will be fixed.

hope this will help someone.

Attitudinize answered 1/8, 2018 at 7:39 Comment(0)
P
2

you must use cmd as adminstrator in windows, or add sudo in linux

Petrapetracca answered 12/9, 2017 at 12:2 Comment(0)
P
0

I used git Bash instead of cmd and it worked.

Providence answered 20/8, 2021 at 15:31 Comment(1)
Can you check what node and npm version you're using in each environment?Goosefish
D
0

First Step

  1. rm package-lock.json
  2. rm -rf node_modules/
  3. npm install -g npm

If above does not works, try changing the node version to previous versions.

Dorthadorthea answered 22/7, 2022 at 5:53 Comment(0)
D
0

For me the solution was as simple as executing this on the git bash:

export GIT_SSH_COMMAND='ssh'

My npm probably was using some other installed ssh program from somewhere on my pc and that one wasn't using the right credentials.

Darken answered 22/8, 2022 at 22:15 Comment(0)
C
0

Saw this error while trying to install a package with quotation marks around the package name:

npm i 'foobar'

should be

npm i foobar

Coriander answered 12/12, 2022 at 22:14 Comment(0)
T
0

I deleted the npm directorie in c:\User\AppData\Roaming. Then, I excuted npm install -g npm. That resolved my problem. Hope it was useful.

Temptation answered 26/8, 2023 at 20:53 Comment(0)
C
0

What happened to me was that I was installing a subpackage in a package as in "hono/cloudflare-workers" which it just resolved to a github repository. I was meaning to install from npm.

Cute answered 1/12, 2023 at 7:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.