npm install gives error “can't find a package.json file”
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寻找一个文件
因此,要么您必须明确告诉npm要安装哪个模块,例如
1 | npm install express |
要么
1 | npm install -g express-generator |
或者您必须添加
1 | npm init |
然后添加所需的内容。请注意,这仅适用于本地安装的模块,不适用于全局模块。
一个简单的示例可能如下所示:
1 2 3 4 5 6 7 | { "name":"myapp", "version":"0.0.1", "dependencies": { "express":"4.0.0" } } |
或类似的东西。有关
1 | sudo npm install npm -g |
测试:运行
1 | npm install |
而已!
https://www.youtube.com/watch?v=wREima9e6vk
我不确定您要在这里做什么:
仅在主目录中的
有两种可能的解决方案:
1)
2)如果您试图安装某些东西作为命令在Shell中使用(您没有节点应用程序),请
>>对于使用程序包管理器控制台的Visual Studio用户,<<
如果要在Visual Studio中使用程序包管理器控制台,并且要执行:
ENOENT: no such file or directory, open
'C:\\Users...\\YourProject\\package.json'
验证您是否在正确的目录中执行命令。
默认情况下,VS在打开Package Manager控制台时使用解决方案文件夹。
执行
现在您必须
现在
使用以下命令创建package.json文件。
1 2 | npm init npm init --yes or -y flag |
[此方法将使用从当前目录提取的信息来生成默认的package.json。]
使用package.json
检查此链接以获取有关如何在本地为应用程序安装express.js的步骤。
但是,如果由于某种原因要在全局范围内安装Express,请确保您所在的目录是Node的安装目录。
在我的Windows 10上,package.json位于
1 2 3 4 | C:\\Program Files\ odejs\ ode_modules\ pm |
以管理员身份打开命令提示符,然后将目录更改为package.json所在的位置。
然后发出install命令。
首先,您不在当前文件夹中...
请使用CD连接到文件夹名称,以访问已查询的项目文件夹...
然后使用代码
解决使用此代码:
1 | npm install npm@latest -g |
我面临以下相同的问题。
npm ERR! errno -4058 npm ERR! syscall open npm ERR! enoent ENOENT: no
such file or directory, open
'D:\\SVenu\\FullStackDevelopment\\Angular\\Angular2_Splitter_CodeSkeleton\\CodeSke
leton\
un\\package.json' npm ERR! enoent This is related to npm not
being able to find a file. npm ERR! enoent
我遇到的问题是,我正在运行命令
只是分享帮助那些像我一样犯小错误的人。
在我的情况下,我的package.json中有错误: