I try running 'npm outdated' from the console in my node project. But I get this error:
npm ERR! Cannot read property 'length' of undefined
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\User\AppData\Roaming\npm-cache\_logs\2019-03-31T12_26_30_745Z-debug.log
This is the error in the log:
199 verbose stack TypeError: Cannot read property 'length' of undefined
199 verbose stack at dotindex (C:\Users\amita\AppData\Roaming\npm\node_modules\npm\node_modules\text-table\index.js:59:32)
199 verbose stack at C:\Users\amita\AppData\Roaming\npm\node_modules\npm\node_modules\text-table\index.js:11:21
199 verbose stack at Array.forEach (<anonymous>)
199 verbose stack at forEach (C:\Users\amita\AppData\Roaming\npm\node_modules\npm\node_modules\text-table\index.js:73:31)
199 verbose stack at C:\Users\amita\AppData\Roaming\npm\node_modules\npm\node_modules\text-table\index.js:10:9
199 verbose stack at Array.reduce (<anonymous>)
199 verbose stack at reduce (C:\Users\amita\AppData\Roaming\npm\node_modules\npm\node_modules\text-table\index.js:63:30)
199 verbose stack at module.exports (C:\Users\amita\AppData\Roaming\npm\node_modules\npm\node_modules\text-table\index.js:9:20)
199 verbose stack at C:\Users\amita\AppData\Roaming\npm\node_modules\npm\lib\outdated.js:130:16
199 verbose stack at cb (C:\Users\amita\AppData\Roaming\npm\node_modules\npm\node_modules\slide\lib\async-map.js:47:24)
199 verbose stack at outdated_ (C:\Users\amita\AppData\Roaming\npm\node_modules\npm\lib\outdated.js:221:12)
199 verbose stack at skip (C:\Users\amita\AppData\Roaming\npm\node_modules\npm\lib\outdated.js:343:5)
199 verbose stack at updateDeps (C:\Users\amita\AppData\Roaming\npm\node_modules\npm\lib\outdated.js:446:7)
199 verbose stack at tryCatcher (C:\Users\amita\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\util.js:16:23)
199 verbose stack at Promise.successAdapter [as _fulfillmentHandler0] (C:\Users\amita\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\nodeify.js:23:30)
199 verbose stack at Promise._settlePromise (C:\Users\amita\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\promise.js:566:21)
200 verbose cwd C:\Users\amita\Ionic\toratlechima
201 verbose Windows_NT 10.0.17134
202 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\amita\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "outdated"
203 verbose node v10.11.0
204 verbose npm v6.9.0
205 error Cannot read property 'length' of undefined
206 verbose exit [ 1, true ]
This also happens when I try to run it globally. Anyone encounter this?
Cannot read property 'length' of undefined npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\User\AppData\Roaming pm-cache\_logs\2019-03-31T12_26_30_745Z-debug.log
A typeerror length of undefined can indicate that the actual type of an operand is different from the expected type. This error can be triggered with.length if the code is trying to access the property before it has been defined, so there needs to be a condition for when it returns undefined, and for when it does not return undefined.
This error can be triggered with .length if the code is trying to access the property before it has been defined, so there needs to be a condition for when it returns undefined, and for when it does not return undefined. In most cases, unless dealing with an external API , we can also just make sure to define it.
The length property returns a number for essentially any object in JavaScript. Typeerrors can be thrown when attempting to change a value that cannot be changed or when using a value in an inappropriate way.
Appears to be fixed in the next release, which isn't out yet.
https://github.com/npm/cli/pull/173
You can install the pre-release to fix it.
npm -g i npm@next
Update
NPM 6.9.2 is out
npm install -g npm
There is a bug in the npm, but you can easily fix it:
npm
folder (i.e. /usr/local/lib/node_modules
) and find a outdated.js
file (i.e. /usr/local/lib/node_modules/npm/lib/outdated.js
for Mac or C:\Users\YOUR_USER_NAME\AppData\Roaming\npm\node_modules\npm\lib\outdated.js
for Windows)Find a function makePretty
and change
deppath
to
deppath || 'global'
in my case it was line #152
I hope it helps! 🙂
You can also try npm upgrade -g
. Worked for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With