31

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"
    }
}
2
  • Can you share the package.json?
    – Adi Levin
    Jan 26, 2016 at 19:11
  • thanks for posting this. May 16, 2018 at 7:09

14 Answers 14

30

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.

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! Jan 26, 2016 at 21:02
  • 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.
    – niczak
    Jul 19, 2017 at 21:49
  • did npm install -g npm and also with sudo but no help
    – lft93ryt
    Aug 27, 2017 at 14:20
  • Thanks Mark. This saved my day :) Dec 8, 2017 at 12:50
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

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
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!

1
  • 1
    Worked for me as well after giving git access to the private repo.
    – kano
    Jul 3, 2017 at 16:35
4

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

npm cache clean --force

npm install

1
  • This one works magic for me. Thanks
    – lyrics
    Dec 7, 2023 at 3:47
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.

2
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.

2

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

0

I used git Bash instead of cmd and it worked.

1
  • Can you check what node and npm version you're using in each environment?
    – BonisTech
    Jan 13, 2022 at 15:44
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.

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.

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

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.

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.