TypeError: Cannot read property 'latest' of undefined - npm-install

I am trying to install some dependencies using npm install, but I am facing issues with it. I new to npm, so I am not able to figure out what is the problem in it?
Below is my command and its result.
npm install –- save babelify#7.2.0 browserify-middleware#7.0.0
express#4.13.3 react#0.14.3 reactify#1.1.1 browser-sync#2.10.0
babel-preset-react#6.3.13 babel-preset-es2015#6.3.13 browserify#12.0.1
react-dom#0.14.3 watchify#3.6.1
npm WARN package.json ReactJS_BluePrints_Scaffold#1.0.0 No repository field.
npm http GET https://registry.npmjs.org/babelify/7.2.0
npm http GET https://registry.npmjs.org/browserify-middleware/7.0.0
npm http GET https://registry.npmjs.org/express/4.13.3
npm http GET https://registry.npmjs.org/react/0.14.3
npm http GET https://registry.npmjs.org/reactify/1.1.1
npm http GET https://registry.npmjs.org/browser-sync/2.10.0
npm http GET https://registry.npmjs.org/babel-preset-react/6.3.13
npm http GET https://registry.npmjs.org/babel-preset-es2015/6.3.13
npm http GET https://registry.npmjs.org/browserify/12.0.1
npm http GET https://registry.npmjs.org/react-dom/0.14.3
npm http GET https://registry.npmjs.org/watchify/3.6.1
npm http GET https://registry.npmjs.org/%E2%80%93-save
npm http 304 https://registry.npmjs.org/react/0.14.3
npm http 304 https://registry.npmjs.org/express/4.13.3
npm http 304 https://registry.npmjs.org/browserify-middleware/7.0.0
npm http 304 https://registry.npmjs.org/babelify/7.2.0
npm http 304 https://registry.npmjs.org/reactify/1.1.1
npm http 304 https://registry.npmjs.org/browser-sync/2.10.0
npm http 304 https://registry.npmjs.org/babel-preset-react/6.3.13
npm http 304 https://registry.npmjs.org/babel-preset-es2015/6.3.13
npm http 304 https://registry.npmjs.org/browserify/12.0.1
npm http 304 https://registry.npmjs.org/react-dom/0.14.3
npm http 304 https://registry.npmjs.org/watchify/3.6.1
npm http 404 https://registry.npmjs.org/%E2%80%93-save
npm ERR! TypeError: Cannot read property 'latest' of undefined
npm ERR! at next (/usr/share/npm/lib/cache.js:687:35)
npm ERR! at /usr/share/npm/lib/cache.js:675:5
npm ERR! at saved (/usr/share/npm/node_modules/npm-registry-client/lib/get.js:142:7)
npm ERR! at /usr/lib/nodejs/graceful-fs/polyfills.js:133:7
npm ERR! at Object.oncomplete (fs.js:107:15)
npm ERR! If you need help, you may report this log at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-#googlegroups.com>
npm ERR! System Linux 4.2.0-27-generic
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" "–-save" "babelify#7.2.0" "browserify-middleware#7.0.0" "express#4.13.3" "react#0.14.3" "reactify#1.1.1" "browser-sync#2.10.0" "babel-preset-react#6.3.13" "babel-preset-es2015#6.3.13" "browserify#12.0.1" "react-dom#0.14.3" "watchify#3.6.1"
npm ERR! cwd /home/user/reactapp
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.3.10
npm ERR! type non_object_property_load
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/user/reactapp/npm-debug.log
npm ERR! not ok code 0

You already got an approved answer but I wanted to add that I ran into a similar issue, receiving the frustrating message (I'm running on Windows):
TypeError: Cannot read property 'latest' of undefined
I tried fixing it by deleting the cache:
npm cache clean
Tried recloning repositories
My issue ended up being that I had two installations of nodejs. I don't know why this caused the error but after I uninstalled both versions and installed a new version, plus then deleted the npm in my appdata, only then did npm work properly again.

The save flag should be --save, not –- save. As the flag is malformed, npm will search for a package named –- (or for –-save since your last edit) .
Try this:
npm install --save babelify#7.2.0 browserify-middleware#7.0.0 express#4.13.3 react#0.14.3 reactify#1.1.1 browser-sync#2.10.0 babel-preset-react#6.3.13 babel-preset-es2015#6.3.13 browserify#12.0.1 react-dom#0.14.3 watchify#3.6.1

Well, I had this same problem and I solved it by installing the latest version of NodeJS. Probably the error is internal in Node.

Related

npm install error "Cannot read property 'latest' of undefined"

I am trying to run the “npm install” command on an admittedly old version of npm and have run into the following issue, even after running “npm cache clean”, We are running version 1.3.6 because we are attempting to rebuild the existing software after a hardware failure. Any pointers would be appreciated.
npm WARN package.json ooi-ui#0.0.1 No repository field.
npm http GET http://registry.npmjs.org/videojs-wavesurfer
npm http 200 http://registry.npmjs.org/videojs-wavesurfer
npm http GET http://registry.npmjs.org/videojs-wavesurfer/-/videojs-wavesurfer-2.11.0.tgz
npm http 200 http://registry.npmjs.org/videojs-wavesurfer/-/videojs-wavesurfer-2.11.0.tgz
npm http GET http://registry.npmjs.org/video.js
npm http GET http://registry.npmjs.org/wavesurfer.js
npm http 200 http://registry.npmjs.org/wavesurfer.js
npm http GET http://registry.npmjs.org/wavesurfer.js/-/wavesurfer.js-4.2.0.tgz
npm http 200 http://registry.npmjs.org/wavesurfer.js/-/wavesurfer.js-4.2.0.tgz
npm http 200 http://registry.npmjs.org/video.js
npm http GET http://registry.npmjs.org/video.js/-/video.js-7.10.2.tgz
npm http 200 http://registry.npmjs.org/video.js/-/video.js-7.10.2.tgz
npm http GET http://registry.npmjs.org/babel/runtime
npm http GET http://registry.npmjs.org/videojs/http-streaming/2.2.4
npm http GET http://registry.npmjs.org/videojs/xhr/2.5.1
npm http GET http://registry.npmjs.org/global/4.3.2
npm http GET http://registry.npmjs.org/keycode
npm http GET http://registry.npmjs.org/safe-json-parse/4.0.0
npm http GET http://registry.npmjs.org/videojs-font/3.2.0
npm http GET http://registry.npmjs.org/videojs-vtt.js
npm http 200 http://registry.npmjs.org/keycode
npm http GET http://registry.npmjs.org/keycode/-/keycode-2.2.0.tgz
npm http 200 http://registry.npmjs.org/safe-json-parse/4.0.0
npm http GET http://registry.npmjs.org/safe-json-parse/-/safe-json-parse-4.0.0.tgz
npm http 404 http://registry.npmjs.org/videojs/http-streaming/2.2.4
npm http 200 http://registry.npmjs.org/global/4.3.2
npm http 405 http://registry.npmjs.org/babel/runtime
npm http GET http://registry.npmjs.org/global/-/global-4.3.2.tgz
npm ERR! TypeError: Cannot read property 'latest' of undefined
npm ERR! at next (/usr/lib/node_modules/npm/lib/cache.js:687:35)
npm ERR! at /usr/lib/node_modules/npm/lib/cache.js:675:5
npm ERR! at saved (/usr/lib/node_modules/npm-registry-client/lib/get.js:148:7)
npm ERR! at /usr/lib/node_modules/graceful-fs/polyfills.js:133:7
npm ERR! at Object.oncomplete (fs.js:108:15)
npm ERR! If you need help, you may report this log at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-#googlegroups.com>
npm ERR! System Linux 2.6.32-754.33.1.el6.x86_64
npm ERR! command "node" "/usr/bin/npm" "install"
npm ERR! cwd /var/ooiui/ooi-ui
npm ERR! node -v v0.10.48
npm ERR! npm -v 1.3.6
npm ERR! type non_object_property_load
npm http 200 http://registry.npmjs.org/keycode/-/keycode-2.2.0.tgz
npm http 200 http://registry.npmjs.org/videojs-vtt.js
npm http 200 http://registry.npmjs.org/safe-json-parse/-/safe-json-parse-4.0.0.tgz
npm ERR! Error: No dist in undefined package
npm ERR! at next (/usr/lib/node_modules/npm/lib/cache.js:746:26)
npm ERR! at /usr/lib/node_modules/npm/lib/cache.js:739:5
npm ERR! at saved (/usr/lib/node_modules/npm-registry-client/lib/get.js:148:7)
npm ERR! at /usr/lib/node_modules/graceful-fs/polyfills.js:133:7
npm ERR! at Object.oncomplete (fs.js:108:15)
npm ERR! If you need help, you may report this log at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-#googlegroups.com>
npm ERR! System Linux 2.6.32-754.33.1.el6.x86_64
npm ERR! command "node" "/usr/bin/npm" "install"
npm ERR! cwd /var/ooiui/ooi-ui
npm ERR! node -v v0.10.48
npm ERR! npm -v 1.3.6
npm http GET http://registry.npmjs.org/videojs-vtt.js/-/videojs-vtt.js-0.15.2.tgz
npm http 404 http://registry.npmjs.org/videojs/xhr/2.5.1
npm http 200 http://registry.npmjs.org/global/-/global-4.3.2.tgz
npm http 200 http://registry.npmjs.org/videojs-vtt.js/-/videojs-vtt.js-0.15.2.tgz
npm http 200 http://registry.npmjs.org/videojs-font/3.2.0
npm http GET http://registry.npmjs.org/videojs-font/-/videojs-font-3.2.0.tgz
npm http 200 http://registry.npmjs.org/videojs-font/-/videojs-font-3.2.0.tgz
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /var/ooiui/ooi-ui/npm-debug.log
npm ERR! not ok code 0
It seems pretty clear that the "404" error code means that npm is not finding the package from the registry. Is this a show stopper, or is there a way forward? Thanks in advance.
The TL;DR on this is update to npm#2.
npm 1.3.6 is 7 years old as of this writing. It is long out of support and the probability that it is incompatible with the current registry is very high.
In comparison, I notice you're running Node.js 0.10.48 which is "only" four years old. And while it too is long out of support, at least 0.10.48 is the most recent version in the 0.10 line. So that's good.
Node.js 0.10.48 shipped with npm 2.x, so somehow, you have an older version of npm than the version that came by default with the version of Node.js you're using. That's often a sign of multiple versions installed on the machine and PATH weirdness that can cause mysterious errors. If you're able to resolve that, it may fix your problem here.
The first dependency listed in your log above is videojs-wavesurfer 2.11.0. I tried installing that with Node.js 0.10.48 and npm 1.3.6. I got a certificate error, so I (temporarily) disabled SSL certificate verification. After doing that, I tried again and got an error similar to yours.
I updated to npm#2 and then was able to install the package without a problem.

This command is not working : npm install --save-dev node--sass#4.7.2

npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/node--sass - Notfound
npm ERR! 404
npm ERR! 404 'node--sass#4.7.2' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name
yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\HARIKA\AppData\Roaming\npm-cache\_logs\2020-05-
27T19_25_06_044Z-debug.log
C:\Users\HARIKA\Desktop\bootstrapassign1\Bootstrap4\conFusion>node-v 'node-v'
is not recognized as an internal or external command,operable program or
batch file.
I am getting this above error while installing node-sass into my windows7 using the command npm install --save-dev node--sass#4.7.2.
Can anyone help me please? Thank you in advance.
You might try reading the error message that NPM is logging:
npm ERR! 404 Not Found - GET https://registry.npmjs.org/node--sass - Notfound
npm ERR! 404
npm ERR! 404 'node--sass#4.7.2' is not in the npm registry.
^^^^^^^^^^
You're trying to install a package named node--sass which doesn't exist in NPM, rather than the desired package, node-sass, which does exist in NPM.

npm login error 301

Why am I getting error 301 Moved Permanently when running npm adduser / npm login?
npm ERR! registry error parsing json
npm ERR! Darwin 16.7.0
npm ERR! argv "/Users/<my-user-name>/.nvm/versions/node/v6.9.2/bin/node" "/Users/<my-user-name>/.nvm/versions/node/v6.9.2/bin/npm" "adduser"
npm ERR! node v6.9.2
npm ERR! npm v3.10.9
npm ERR! Unexpected token < in JSON at position 0
npm ERR! <html>
npm ERR! <head><title>301 Moved Permanently</title></head>
npm ERR! <body bgcolor="white">
npm ERR! <center><h1>301 Moved Permanently</h1></center>
npm ERR! <hr><center>nginx/1.8.1</center>
npm ERR! </body>
npm ERR! </html>
I am trying to publish a package into npm, and had no issues logging in yesterady (verified via npm whoami). I know that I have the correct npm username and password etc. because I can verify by logging into npm (https://www.npmjs.com/login). And as you can see, I am running node 6.9.2 and npm 3.10.9 (which should be latest).
Any ideas why this could be?
Maybe your client was pointing to a wrong/outdated registry URL?
For me it was pointing to http://registry.npmjs.org/ instead of https://registry.npmjs.org/ (see https://docs.npmjs.com/misc/registry):
$ npm adduser
npm ERR! code E301
npm ERR! Registry returned 301 for POST on
http://registry.npmjs.org/-/v1/login
...
$ npm config get registry
http://registry.npmjs.org/
$ npm config set registry https://registry.npmjs.org/
$ npm adduser
Username:
...

OpenLayers installation using npm - packet not found

I am trying to install openlayers within my Express project using npm to create custom builds but I get the following error:
npm ERR! 404 Not Found
npm ERR! 404
npm ERR! 404 'mapbox/vector-tile' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it
npm ERR! 404 It was specified as a dependency of 'openlayers'
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, or http url, or git url.
npm ERR! System Linux 3.16.0-4-amd64
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" "openlayers"
npm ERR! node -v v0.10.29
npm ERR! npm -v 1.4.21
npm ERR! code E404
npm ERR!
npm ERR! not ok code 0
I tried updating npm and installing vector-tile manually but it didn't help.
What am I doing wrong?
EDIT: same error when calling npm install ol instead of npm install openlayers.
Use a more recent version of node and npm, preferably the LTS versions

sudo npm install -g mocha not working

I am just running a basic mocha install command and its throwing the error in the mac terminal, Please suggest seeing the logs what can i do to get this running, Really appreciate the help.
AUK03154:~ itrmg$ sudo npm install –g mocha
Password:
npm ERR! 404 404 Not Found: %E2%80%93g
npm ERR! 404
npm ERR! 404 '%E2%80%93g' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, or http url, or git url.
npm ERR! System Darwin 13.1.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "–g" "mocha"
npm ERR! cwd /Users/itrmg
npm ERR! node -v v0.10.29
npm ERR! npm -v 1.4.14
npm ERR! code E404
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/itrmg/npm-debug.log
npm ERR! not ok code 0
Thanks
Deepesh
If you decode %E2%80%93g, you get -g. Something is wrong with the - character in -g. I copied the – character from your question to get its character code:
'–'.charCodeAt(0)
8211
Then I typed the dash myself:
'-'.charCodeAt(0)
45
As you can see your dash has a different character code. If you copy this command, it should work:
npm install -g mocha
If you did a copy-paste of that command from another webpage/text-editor, there are some unwanted characters which get copied. Try typing the same command manually, the error should go away.