npm can't find package.json

2019-01-10 04:19发布

I'm trying to install the dependencies of some example Express apps I've downloaded but all of the apps throw the same error:

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

Does anyone know what might be the root of this problem?
I'm running:

  • Windows 7 64 bit
  • npm 1.1.1
  • node 6.11
  • express 2.5.8

21条回答
一夜七次
2楼-- · 2019-01-10 04:41

Beginners usually try use command on random localization. after downloading or creating project you have to go into this project. Inside is file package.json

cd <path_to_project>
npm install
查看更多
干净又极端
3楼-- · 2019-01-10 04:42

try re-install Node.js

curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -

sudo apt-get install -y nodejs

sudo apt-get install -y build-essential

and update npm

curl -L https://npmjs.com/install.sh | sudo sh
查看更多
乱世女痞
4楼-- · 2019-01-10 04:42

For the following command

sudo npm install react browserify watchify babelify --save-dev

I got same error

saveError ENOENT: no such file or directory, open '/Users/Path/package.json'

But when I run the command

sudo npm install -gd react browserify watchify babelify --save-dev

then no missing file or directory message appeared.

查看更多
smile是对你的礼貌
5楼-- · 2019-01-10 04:44

I'll be brief but deadly. :) install -d will not work for you. It's simple. Try

$ npm install -g express
查看更多
Bombasti
6楼-- · 2019-01-10 04:44

ok, try to go to the home "user@user:~$ " (cd + enter key), and npm install -g your your_module.

查看更多
闹够了就滚
7楼-- · 2019-01-10 04:46

I have run npm install -y to skip the question step for creating the missing file package.json, y means yes

查看更多
登录 后发表回答