node.js - npm 安装错误为 errno -2

标签 node.js reactjs npm errno

我正在尝试安装 npm,但它显示以下错误:

   npm ERR! install Couldn't read dependencies
   npm ERR! Darwin 14.5.0
   npm ERR! argv  "/Users/bunniehsieh/.nvm/versions/node/v4.1.0/bin/node" "/Users/bunniehsieh/.nvm/versions/node/v4.1.0/bin/npm" "install"
   npm ERR! node v4.1.0
   npm ERR! npm  v2.14.3
   npm ERR! path /Users/bunniehsieh/package.json
   npm ERR! code ENOPACKAGEJSON
   npm ERR! errno -2
   npm ERR! syscall open

   npm ERR! package.json ENOENT: no such file or directory, open    '/Users/bunniehsieh/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! Please include the following file with any support request:
  npm ERR!     /Users/bunniehsieh/npm-debug.log

我尝试卸载然后再次安装,但没有成功,请给我一些建议或任何帮助,谢谢!!!!!!

最佳答案

您无需安装任何内容。

Npm 将在当前目录中查找名为 package.json 的文件。该文件包含项目的各种信息,包括依赖项。
您需要创建 (npm init) 或从现有项目导入该文件。

您还可以通过将其名称指定给 npm 来指定要手动安装的包:

npm install package_name

请完整阅读 official documentation

关于node.js - npm 安装错误为 errno -2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32690862/

相关文章:

node.js - 如何为房间中的所有客户端更新套接字对象? (socket.io)

node.js - 如何在不终止进程的情况下停止 node.js 服务器?

javascript - MongoDB 使用凭据连接

javascript - 在 ReactJS 中获取状态中的搜索值

node.js - GitLab CI/CD shell 执行器 : npm command not found

node.js - Node http-server 即使在关闭后仍保留端口 8080

node.js - 使用express-validator进行快速验证错误

css - 如何为 slider 添加 CSS

javascript - RxJS 和 React 多次点击元素形成单个数据数组

node.js - node dist/server.js 退出时没有错误消息