npm install
/npm install -g
命令在 Windows 7 中不起作用
Node.js 安装正确,node.js 版本为 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.
最佳答案
你没有说你想安装什么模块 - 因此 npm 寻找一个描述你的依赖关系的文件 package.json
,显然这个文件丢失了。
所以要么你必须明确告诉 npm 要安装哪个模块,例如
npm install express
或
npm install -g express-generator
或者您必须添加一个 package.json
文件并在此处注册您的模块。获取此类文件的最简单方法是让 npm 通过运行来创建一个
npm init
然后添加您需要的内容。请注意,这仅适用于本地安装的模块,不适用于全局模块。
一个简单的例子可能如下所示:
{
"name": "myapp",
"version": "0.0.1",
"dependencies": {
"express": "4.0.0"
}
}
或类似的东西。有关 package.json
文件的更多信息,请参阅其 official documentation和 this interactive guide .
关于node.js - npm install 给出错误 "can' t find a package.json file",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24468041/