34

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" } } 
0

15 Answers 15

32

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.

Sign up to request clarification or add additional context in comments.

4 Comments

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!
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.
did npm install -g npm and also with sudo but no help
now, npm only not working. module not found error
9

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

Comments

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 

Comments

6

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

npm cache clean --force

npm install

Comments

5

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 Comment

Worked for me as well after giving git access to the private repo.
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.

1 Comment

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.

Comments

2

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

Comments

0

I used git Bash instead of cmd and it worked.

1 Comment

Can you check what node and npm version you're using in each environment?
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.

Comments

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.

Comments

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

Comments

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.

Comments

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.

Comments

0

I was getting the same verbose stack Error: exited with error code: 128 and tons of warn tar ENOENT: no such file or directory where present in my log.

I use Cygwin all the time in my Windows 11 environment. I also use nvm-windows to manage my Node versions. I noticed what was going on using this command:

nvm debug 

And I got the following relevant output:

PROBLEMS DETECTED ----------------- "\?\C:\tools\cygwin\bin\cygwin-console-helper.exe" not recognized: the Command Prompt and Powershell are the only officially supported consoles. Some features may not work as expected.

So I followed that advice and used cmd to run npm i and my problem was solved! I hope someone finds this useful.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.