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
@maurelian did you try re-installing all node modules?
also, can you install the previous version: npm install [email protected]?
closing it, please re-open if the issue persists
Long story short: delete node_modules folder and package-lock.json file.
_Duplicate of https://github.com/npm/npm/issues/17858 and https://github.com/npm/npm/issues/18042_
same issues
2018-02-16T03_32_06_898Z-debug.log
Also be sure that you are simply not running a build watch. That was my issue.
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 [email protected] 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!
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\npmnode_modules\npm\lib\unbuild.js:61:24 file and found that for some libraries I was getting package information without the name.
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


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.
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.
still seeing this issue in node 10.13.0 with npm 6.4.1
@rkretzer Thank you so much. You've saved my life.
Most helpful comment
Long story short: delete node_modules folder and package-lock.json file.
_Duplicate of https://github.com/npm/npm/issues/17858 and https://github.com/npm/npm/issues/18042_