10

I am just trying to run npm install . in a local directory, and keep getting these errors:

npm ERR! install Couldn't read dependencies
npm ERR! Darwin 15.2.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "."
npm ERR! node v4.4.6
npm ERR! npm  v2.15.5
npm ERR! code EISDIR
npm ERR! errno -21
npm ERR! syscall read

npm ERR! eisdir EISDIR: illegal operation on a directory, read
npm ERR! eisdir This is most likely not a problem with npm itself
npm ERR! eisdir and is related to npm not being able to find a     package.json in
npm ERR! eisdir a package you are trying to install.

All I'm doing is cd'ing into my directory and running npm install . I have a packages.json file in there, as well. Any idea why this isn't working??? EDIT: contents of packages.json file is below:

{
  "name": "speech-recognition",
 "version": "1.0.0",
 "description": "speech recognition app",
 "main": "application.js",
 "scripts": {
   "test": "echo \"Error: no test specified\" && exit 1",
   "start": "node server.js"
 },
 "author": "Lisa Buch",
 "license": "ISC"
 }
2
  • you say you have package.json directory in there. Mind sharing its contents? It's supposed to be a file, not a directory so I'm curious what's in it. Commented Jun 27, 2016 at 6:26
  • I'm sorry, I meant file! I'll add the contents of it to my post now. Commented Jun 27, 2016 at 6:29

8 Answers 8

18

Please check your current directory. It should contain a package.json file with proper structure and dependencies.

https://docs.npmjs.com/files/package.json

If you don't have a package.json file, means you are creating a project from scratch. In this case you can create package.json file using following command.

npm init

and install the packages with providing the package name with npm install command. e.g. if you want to install express package. use the following command

npm install express --save

Here --save option will update you package.json file with the package and its version.

Sign up to request clarification or add additional context in comments.

9 Comments

I ran npm init and the package was created correctly. Now, when I run npm install, I get the following messages: npm WARN package.json [email protected] No description npm WARN package.json [email protected] No repository field. npm WARN package.json [email protected] No README data, however, the node_modules directory still does not exist....maybe those fields MUST have something in them?
npm intstall is to install the packages from the list of "dependencies" from package.json file
to install to package initially I think you should prefer the specific command related to that package
e.g. If you want to install Express. then use the following command
npm install express --save
|
2

The issue seems to be self descriptive:

npm ERR! eisdir and is related to npm not being able to find a
package.json in

This means that npm install is not able to find the package.json file in the folder

You can run npm init on the folder. This will ask a series of project set up questions and at the end will create a package.json file.

Then you can run npm install -save-dev on the folder to install the dependencies

1 Comment

npm intsall => please correct. (because its like npm integer sall =)
1

Try it with npm install --save

1 Comment

0

I usually don't make this mistake but I had "dependencies" spelled wrong in the root package.json file. Hope it helps.

1 Comment

This is not an answer to the question and is a speculative guess, best limited to the comments section, only in the case where this question was NOT answered two years ago.
0

If you have a package-lock.json file in the directory you are trying to run npm install... delete the package-lock.json file and run npm install again, this will generate all files and folders needed.

Comments

0

You might already be having working application with package.json just paste it in new project and then enter the command npm install

Comments

0

Agree with @AnthonyAstige - I had the same issue that no node_modules folder was being created...at least that's what I thought. I had clicked/dragged the folder I was working with into VSCode prior to running npm install express --save. @brk got me looking in other dir/folders and I found the path to the node_modules folder was in my home dir and not the folder I had dragged into VSCode.

Moral of the story...make sure you are in the correct dir, aka your project's root directory before running the install. I know, rookie mistake but apparently this is a widely discussed topic.

Comments

0

1.

Try these possible solutions.

• Delete the node_modules folder and also delete the package-lock.json file(if already present).

• Clear the cache using npm cache clean --verify.

• And then run npm install again.

2.

if package.json is missing

• Run npm init. It will create the package.json file on the fly for you.

• After this proceed as written in 1st Solution.

3.

This bug may be caused by many different things. Maybe your global packages are corrupted in some way.

• Install Node Version Manager (or NVM for Windows) and install Node version 10.16.1. It is a much stable version for development. This should also change your NPM version so that may also help.

• Delete the package-lock.json file(if already present).

• Force clear cache npm cache clean --force

• You can also try clearing your %temp% and %roaming% AppData/npm-cache

• Run npm install --force.

• If this error still occurs, consider using another shell.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.