npm从终端安装错误

25 javascript node.js npm backbone.js angularjs

我正在尝试在我的mac中安装节点..我收到以下错误...我从节点站点下载节点并运行该程序包...你们可以告诉我为什么我面临的错误..当我做的时候npm安装

MacBook-Pro:~ Raj$ npm install
npm ERR! install Couldn't read dependencies
npm ERR! package.json ENOENT, open '/Users/Raj/package.json'
npm ERR! package.json This is most likely not a problem with npm itself.
npm ERR! package.json npm can't find a package.json file in your current directory.

npm ERR! System Darwin 13.0.0
npm ERR! command "node" "/usr/local/bin/npm" "install"
npm ERR! cwd /Users/Raj
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.3
npm ERR! path /Users/Raj/package.json
npm ERR! code ENOPACKAGEJSON
npm ERR! errno 34
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/Raj/npm-debug.log
npm ERR! not ok code 0
Run Code Online (Sandbox Code Playgroud)

小智 36

仅运行"npm install"将查找package.json中列出的依赖项.你得到的错误说你没有设置package.json文件(或者你在错误的目录中).

如果您尝试安装特定软件包,则应使用"npm install {package name}".有关该命令的更多信息,请参见此处.

否则,您需要为依赖项创建package.json文件,或者转到正确的目录,然后运行"npm install".

  • 错误的目录,ding ding ding是我的问题.谢谢@John (2认同)
  • 我在正确的目录中,我有`package.json`文件,JSON有效,并且仍然出现错误... (2认同)

MMe*_*rum 6

当我尝试在安装 Node.js 之前打开的终端窗口中运行“npm install”时,遇到了这个问题。

打开一个新的终端窗口(即 bash 会话)有效。(想必这为 npm 的正确运行提供了正确的环境变量。)