Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
929 views
in Technique[技术] by (71.8m points)

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

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...