Rice
Rice

Reputation: 3531

npm throws ENOENT warnings on every install/uninstall/ls

I am trying to do npm install on a Windows 7 shell for some js test development packages directly in a source code repository I cloned locally, in this case karma, chai and mocha.. I consistently get the following errors when trying to install, uninstall other packages.

npm WARN ENOENT ENOENT, open '..SourceDirectory\package.json'
npm WARN EPACKAGEJSON ..SourceDirectory\ No description
npm WARN EPACKAGEJSON ..SourceDirectory\ No repository field.
npm WARN EPACKAGEJSON ..SourceDirectory\ No README data
npm WARN EPACKAGEJSON ..SourceDirectory\ No license field.

npm ls also yields

npm ERR! error in ..SourceDirectory\: ENOENT, open '..SourceDirectory\package
.json'

I did pull the beta of the Windows npm upgrade from

Windows Upgrade

because I was running into the file system path length error. I do not have a package.json dependency list located in the warnings' path. Is there a configuration step I missed?

Upvotes: 34

Views: 58656

Answers (8)

Leon Johnson
Leon Johnson

Reputation: 33

You need to switch into the directory that you're working and then run:

npm -init

After running that, continue to press enter until you get to the end.

Upvotes: 0

AJ_Temitayo
AJ_Temitayo

Reputation: 11

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

Upvotes: 1

Vijay Kalathiya
Vijay Kalathiya

Reputation: 19

Had a same problem resolve by

cd [project folder]
npm cache clean --force
npm install -d
sudo npm update

Upvotes: 0

Divya Jalan
Divya Jalan

Reputation: 79

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

npm cache clean --force

Upvotes: 2

user5556825
user5556825

Reputation:

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"

Upvotes: 43

saksham
saksham

Reputation: 3324

I also faced the same problem but i was doing a silly mistake

if your npm is installed properly then problem can be confusion between developer to select the current directory to install .js packages. Actually installing anything using npm requires Package.json file in the directory you want to install your package

eg: npm install abcd

now if you want to install abcd package via npm make sure you are in the right directory using terminal

eg: my npm directory on my mac is

/Users/myMac/node_modules/assert-plus/package.json

so if make sure you are in directory

/Users/myMac/node_modules/assert-plus

select this directory via terminal and then write npm install abcd

Upvotes: 0

Abbas Gadhia
Abbas Gadhia

Reputation: 15090

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....)

Upvotes: 1

ARB
ARB

Reputation: 327

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

Upvotes: 8

Related Questions