npm 找不到 package.json

新手上路,请多包涵

我正在尝试安装一些示例的依赖项:我已下载的 npm express 2.5.8 ,但所有应用程序都抛出相同的错误:

 c:\node\stylus>npm install -d
npm info it worked if it ends with ok
npm info using npm@1.1.1
npm info using node@v0.6.11
npm ERR! Couldn't read dependencies.

npm ERR! Error: ENOENT, no such file or directory 'c:\node\stylus\package.json'
npm ERR! You may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <npm-@googlegroups.com>
npm ERR!
npm ERR! System Windows_NT 6.1.7600
npm ERR! command "C:\\Program Files (x86)\\nodejs\\\\node.exe" "C:\\Program File
s (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-d"
npm ERR! cwd c:\node\stylus
npm ERR! node -v v0.6.11
npm ERR! npm -v 1.1.1
npm ERR! path c:\node\stylus\package.json
npm ERR! code ENOENT
npm ERR! message ENOENT, no such file or directory 'c:\node\stylus\package.json'

npm ERR! errno {}
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     c:\node\stylus\npm-debug.log
npm not ok

阻塞似乎是:

没有这样的文件或目录 ‘c:\node\stylus\package.json

我是否错过了创建 package.json 的步骤?

我在跑:

  • 视窗 7 64 位
  • npm 1.1.1
  • 节点 6.11
  • 表达 2.5.8

原文由 imjp 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 1.2k
2 个回答

2021 年更新

npm init

有关详细信息,请参阅 Deepali 的 答案。

原始过时的答案

我想你忘了为 express 设置目录:

 express <yourdirectory>

一旦你这样做了,你应该能够看到一堆文件,然后你应该运行命令:

 npm install -d

问候。

原文由 Aldo 发布,翻译遵循 CC BY-SA 4.0 许可协议

我认为 npm init 会创建你丢失的 package.json 文件。对于同一个案例,它对我有用。

原文由 Deepali Agarwal 发布,翻译遵循 CC BY-SA 3.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题