npm install error from the terminal
Solution 1
Running just "npm install" will look for dependencies listed in your package.json. The error you're getting says that you don't have a package.json file set up (or you're in the wrong directory).
If you're trying to install a specific package, you should use 'npm install {package name}'. See here for more info about the command.
Otherwise, you'll need to create a package.json file for your dependencies or go to the right directory and then run 'npm install'.
Solution 2
I had this problem when trying to run 'npm install' in a Terminal window which had been opened before installing Node.js.
Opening a new Terminal window (i.e. bash session) worked. (Presumably this provided the correct environment variables for npm to run correctly.)
Solution 3
In my case it was due to a bad URL (http://
instead of git://
, no .git
at the end) for one of the dependencies.
Solution 4
I came across this, and my issue was using an older version of node (3.X), when a newer version was required.
The error message actually suggested this as well:
...
Make sure you have the latest version of node.js and npm installed
...
So the solution may be as simple as upgrading node/npm. You can easily do this using nvm, the "Node Version Manager"
After you've installed nvm
, you can install and use the latest version of node by simply running this command:
nvm install node
For example:
$ nvm install node
Downloading https://nodejs.org/dist/v8.2.1/node-v8.2.1-darwin-x64.tar.xz...
######################################################################## 100.0%
Now using node v8.2.1 (npm v5.3.0)
$ node --version
v8.2.1
Solution 5
You're likely not in the node directory. Try switching to the directory that you unpacked node to and try running the command there.
Admin
Updated on October 06, 2021Comments
-
Admin over 2 years
I am trying to install node in my mac.. i am getting the following error... i downloaded the node from node site and ran that package... can you guys tell me why i am facing that errror..when i do npm install
MacBook-Pro:~ Raj$ npm install npm ERR! install Couldn't read dependencies npm ERR! package.json ENOENT, open '/Users/Raj/package.json' npm ERR! package.json This is most likely not a problem with npm itself. npm ERR! package.json npm can't find a package.json file in your current directory. npm ERR! System Darwin 13.0.0 npm ERR! command "node" "/usr/local/bin/npm" "install" npm ERR! cwd /Users/Raj npm ERR! node -v v0.10.26 npm ERR! npm -v 1.4.3 npm ERR! path /Users/Raj/package.json npm ERR! code ENOPACKAGEJSON npm ERR! errno 34 npm ERR! npm ERR! Additional logging details can be found in: npm ERR! /Users/Raj/npm-debug.log npm ERR! not ok code 0