Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm install ends with "npm ERR! Cannot read property '0' of undefined" #601

Closed
maurelian opened this issue Oct 22, 2017 · 12 comments
Closed
Labels

Comments

@maurelian
Copy link

What version of Ajv are you using? Does the issue happen if you use the latest version?
5.2.4

Yes.

Expected behavior

I can install AJV using npm

Observed behavior

I cannot install it.

$ npm install ajv
npm ERR! Cannot read property '0' of undefined

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/primary/.npm/_logs/2017-10-22T15_44_19_461Z-debug.log

Logs:
2017-10-22T15_44_19_461Z-debug.log

@epoberezkin
Copy link
Member

epoberezkin commented Oct 22, 2017

@maurelian did you try re-installing all node modules?

@epoberezkin
Copy link
Member

also, can you install the previous version: npm install ajv@5.2.3?

@epoberezkin
Copy link
Member

closing it, please re-open if the issue persists

@codyx
Copy link

codyx commented Nov 6, 2017

Long story short: delete node_modules folder and package-lock.json file.

Duplicate of npm/npm#17858 and npm/npm#18042

@mrpatel15
Copy link

mrpatel15 commented Feb 16, 2018

same issues
2018-02-16T03_32_06_898Z-debug.log

@prmichaelsen
Copy link

Also be sure that you are simply not running a build watch. That was my issue.

@koteisaev
Copy link

Just got that error after any try to use node 8.15.1 and npm 6.9.0 either via nvm or viaoffical node installer.
48387 warn selfcad-api-server@0.0.0 No repository field. 48388 verbose stack TypeError: Cannot read property '0' of undefined 48388 verbose stack at rmStuff (C:\Users\kote\AppData\Roaming\npm\node_modules\npm\lib\unbuild.js:61:24) 48388 verbose stack at tryCatcher (C:\Users\kote\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\util.js:16:23) 48388 verbose stack at ret (eval at makeNodePromisifiedEval (C:\Users\kote\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\promisify.js:184:12), <anonymous>:13:39) 48388 verbose stack at lifecycle.then.then (C:\Users\kote\AppData\Roaming\npm\node_modules\npm\lib\install\action\unbuild.js:12:12) 48388 verbose stack at tryCatcher (C:\Users\kote\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\util.js:16:23) 48388 verbose stack at Promise._settlePromiseFromHandler (C:\Users\kote\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\promise.js:512:31) 48388 verbose stack at Promise._settlePromise (C:\Users\kote\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\promise.js:569:18) 48388 verbose stack at Promise._settlePromise0 (C:\Users\kote\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\promise.js:614:10) 48388 verbose stack at Promise._settlePromises (C:\Users\kote\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\promise.js:694:18) 48388 verbose stack at Promise._fulfill (C:\Users\kote\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\promise.js:638:18) 48388 verbose stack at C:\Users\kote\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\nodeback.js:42:21 48388 verbose stack at <anonymous> 48389 verbose cwd F:\repos\node_gcs\backend 48390 verbose Windows_NT 10.0.17134 48391 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\kote\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" 48392 verbose node v8.15.1 48393 verbose npm v6.9.0 48394 error Cannot read property '0' of undefined 48395 verbose exit [ 1, true ]
Really frustrating.
I just ried ot upgrade our project to node 8 and spent few hours on this problem!

@alpha3media
Copy link

Hi,
I found the issue. It seems like it is linked to all modules in package.json with "*", latest version. By changing the asterix with the latest version of each package it fix the problem.

I logged the what we are receiving on AppData\Roaming\npm\node_modules\npm\lib\unbuild.js:61:24 file and found that for some libraries I was getting package information without the name.

@trackmystories
Copy link

Hey,
this issue is linked to the node_modules, I know this because I installed firebase and it did not complete installation however was registered to package.json.

I first removed firebase from package.json and hit npm install but the issue still persist.
I resolved this issue with the following steps (Please see the screen shot attached) :

step one: remove the faulty dependency from package.json in my case this was firebase.

step two : delete node_modules with rm -rf node_modules

step three : re-install node_modules with npm install
Screenshot 2019-04-27 at 10 24 24 PM
Screenshot 2019-04-27 at 10 32 28 PM

step four : npm start and it should work, at this stage you can reinstall the module which was cause an error which i did in my case firebase.

@rkretzer
Copy link

rkretzer commented May 3, 2019

Certainly no thorough and persistent solution, but patching my

/usr/local/lib/node_modules/npm/lib/unbuild.js:61

to

var parent = (pkg.name && pkg.name[0] === '@') ? path.dirname(path.dirname(folder)) : path.dirname(folder), hence adding pkg.name && to the condition and checking, if the package name exists, enabled me to make my installation work as a hotfix. Have spent hours frustrated before with this problem.

@A30001835
Copy link

still seeing this issue in node 10.13.0 with npm 6.4.1

@aaronamm
Copy link

@rkretzer Thank you so much. You've saved my life.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests