imj*_*mjp 135 node.js npm express
我正在尝试安装我已下载的一些示例Express应用程序的依赖项,但所有应用程序都抛出相同的错误:
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
Run Code Online (Sandbox Code Playgroud)
有谁知道这个问题的根源是什么?
我在跑:
小智 81
我会简短而致命.:) install -d不适合你.这很简单.尝试
$ npm install -g express
Run Code Online (Sandbox Code Playgroud)
Ald*_*ldo 68
更新2018年
这已成为一个非常受欢迎的问题,我的回答(虽然标记为正确)已不再有效.请参阅下面的Deepali的答案:
npm init
Run Code Online (Sandbox Code Playgroud)
原始过时的答案
我想你忘了设置express的目录:
express <yourdirectory>
Run Code Online (Sandbox Code Playgroud)
一旦你这样做,你应该能够看到一堆文件,然后你应该运行命令:
npm install -d
Run Code Online (Sandbox Code Playgroud)
问候.
Ela*_*van 57
完成以下步骤,您将获得package.json文件.
npm --version
npm install express
npm init -y
Run Code Online (Sandbox Code Playgroud)
链接: http ://www.codingslover.com/2017/02/npm-node-js-cant-find-packagejson.html
Ger*_*rry 16
如果谷歌搜索"没有这样的文件或目录package.json"发送到这里,那么你可能正在使用一个非常旧版本的Node.js
以下页面提供了如何在许多操作系统和发行版上轻松安装最新稳定版的良好说明:
https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager
初学者通常从随机位置尝试 npm 命令。下载或创建项目后,您必须 cd 到此项目文件夹中。里面是 package.json 文件。
cd <path_to_project>
npm install
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
359893 次 |
| 最近记录: |