Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm throws ENOENT warnings on every install/uninstall/ls

Tags:

node.js

npm

Error message might be caused by missing package.json file. Change directory to your project's local directory, as an example (instead, use current working directory of your project):

cd /var/www/nodeBot

Following string will write package.json:

npm init

Answer menu-driven questions or use --yes to blast past them. Then press enter at the end to write out the file. You might see something like:

Wrote to /usr/local/bin/package.json:

{
  "name": "bin",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "dependencies": {
    "twit": "^2.1.1"
},
  "devDependencies": {},
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}

npm is node.js's package manager. package.json becomes npm's configuration or settings file. The twit dependency was a program installed into my project dir. npm install twit


If a package.json file exists in your project's directory, you can use a text editor to fill in empty data fields that can also cause error messages.

Find the description field in the package.json file and manually add a description:

"description": "This is my latest disruptive technology app.",

In license field you can add ISC which basically means open source project:

"license": "ISC"

I was facing the same problem, so i tried this commands. It works for me

npm install npm@latest -g

Hope it will work for you as well


I ran the following command and this worked for me!!!

npm cache clean --force

There could be a problem with your "engines" value in the parent package.json file.

For example, i had

"engines" : {
    "node": ">=6.10.0",
    "npm": ">=4.3.0"
}

I removed the "npm" key and it just worked (Scratching my head....)


I had this issue myself, all i did was to remove the package-lock.json file and now it works. Hope this helps someone.