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条回答
SAY GOODBYE
2楼-- · 2019-01-10 04:58

Use the command in win7/win8/win10 (CD) for moving folders:

  1. Enter your projects folder

  2. Run: npm install -d

查看更多
爷的心禁止访问
3楼-- · 2019-01-10 04:58

It by itself says that package.json is not available in your project. So, to create package.json, use the following steps:

  1. open command prompt on your project directory
  2. npm init (it will ask you to enter lots of entries like name, version, desc, etc., enter some random values and click enter).
  3. type yes and click enter

Now try again.

查看更多
看我几分像从前
4楼-- · 2019-01-10 04:59

I had a similar problem with npm. The problem was that I had the project inside two folders of the same name. I resolved it by renaming one of the folders to something else (outer folder recommended).

查看更多
神经病院院长
5楼-- · 2019-01-10 04:59

Thank you! I also tried many options for this. I am also using windows.This command helped and saved my time:

npm install -g npm@lts
查看更多
Fickle 薄情
6楼-- · 2019-01-10 05:00

My issue was I didn't have a package.json file for some reason. After I wget this file into my directory, I was able to run npm install

https://raw.githubusercontent.com/twbs/bootstrap/master/package.json

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

just install any package you want with -g

npm install -g express

查看更多
登录 后发表回答