Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm install gives error "can't find a package.json file"

Tags:

node.js

npm

npm install / npm install -g command is not working in Windows 7

Node.js is installed properly, node.js version is v0.10.28

Couldn't read dependencies
ENOENT, open '"filepath"\package.json'
This is most likely not a problem with npm itself.
npm can't find a package.json file in your current directory.

Photo

like image 226
Subhajit Panja Avatar asked Jun 28 '14 14:06

Subhajit Panja


People also ask

Does npm install use package json?

By default, npm install will install all modules listed as dependencies in package. json .

Why npm install is failing?

This cause of this error is that one of the dependencies you define in your package. json file fails to be installed properly on your computer. This means that npm fails to install the node-sass module that's added as a dependency to the n-app project.


1 Answers

You don't say what module you want to install - hence npm looks for a file package.json which describes your dependencies, and obviously this file is missing.

So either you have to explicitly tell npm which module to install, e.g.

npm install express 

or

npm install -g express-generator 

or you have to add a package.json file and register your modules here. The easiest way to get such a file is to let npm create one by running

npm init 

and then add what you need. Please note that this does only work for locally installed modules, not for global ones.

A simple example might look like this:

{   "name": "myapp",   "version": "0.0.1",   "dependencies": {     "express": "4.0.0"   } } 

or something like that. For more info on the package.json file see its official documentation and this interactive guide.

like image 180
Golo Roden Avatar answered Oct 15 '22 14:10

Golo Roden