16

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"
    }
}
andy mccullough
  • 6,646
  • 6
  • 24
  • 39

8 Answers8

20

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.

Mark Stosberg
  • 11,351
  • 6
  • 37
  • 47
5

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

Archdoog
  • 664
  • 8
  • 6
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.

Mark Stosberg
  • 11,351
  • 6
  • 37
  • 47
龙云翔
  • 31
  • 1
3

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://git@bitbucket.org/{user}/{repository}.git
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.

NoNaMe
  • 5,410
  • 30
  • 73
  • 98
2

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!

The Coder
  • 3,277
  • 1
  • 24
  • 34
2

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

Zakaria.dem
  • 292
  • 3
  • 9
2

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

npm cache clean --force

npm install

Hasangi
  • 250
  • 6
  • 17