npm找不到package.json

时间:2022-12-30 07:21:10

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
  • Windows 7 64位
  • npm 1.1.1
  • npm 1.1.1
  • node 6.11
  • 节点6.11
  • express 2.5.8
  • 表达2.5.8

19 个解决方案

#1


23  

I think you forgot to setup the directory for express:

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

express <yourdirectory>

Once you do that you should be able to see a bunch of files, you should then run the command:

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

npm install -d

Regards.

的问候。

#2


70  

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

我将简短而致命。安装-d不会为你工作。这很简单。试一试

$ npm install -g express

#3


58  

I think, npm init will create your missing package.json file. It works for me for the same case.

我认为,npm init将会创建您丢失的包。json文件。对我来说也是一样的。

#4


37  

Follwing the below steps you well get package.json file.

下面的步骤你会得到一个包裹。json文件。

npm --version
npm install express
npm init -y

Link : http://www.codingslover.com/2017/02/npm-node-js-cant-find-packagejson.html

链接:http://www.codingslover.com/2017/02/npm-node-js-cant-find-packagejson.html

#5


15  

If Googling "no such file or directory package.json" sent you here, then you might be using a very old version of Node.js

如果google“没有这样的文件或目录包”。json“发送给您,然后您可能会使用非常旧版本的Node.js。”

The following page has good instructions of how to easily install the latest stable on many Operating systems and distros:

下面的页面很好地说明了如何在许多操作系统和发行版上轻松安装最新的稳定版:

https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager

https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager

#6


6  

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

使用win7/win8/win10 (CD)中的命令来移动文件夹:

  1. Enter your projects folder

    输入您的项目文件夹

  2. Run: npm install -d

    运行:npm安装- d

#7


2  

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

我的问题是我没有一个包裹。出于某种原因,json文件。在我将这个文件放入我的目录之后,我就可以运行npm安装了。

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

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

#8


2  

try re-install Node.js

尝试重新安装node . js

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

curl - sl https://deb.nodesource.com/setup_4.x | sudo - e bash -。

sudo apt-get install -y nodejs

sudo apt-get安装-y nodejs。

sudo apt-get install -y build-essential

and update npm

和更新npm

curl -L https://npmjs.com/install.sh | sudo sh

#9


2  

Node comes with npm installed so you should have a version of npm. However, npm gets updated more frequently than Node does, so you'll want to make sure it's the latest version.

节点是由npm安装的,所以您应该有一个npm版本。但是,npm比Node更频繁地更新,所以您需要确保它是最新版本。

sudo npm install npm -g

Test:

测试:

npm -v //The version should be higher than 2.1.8

After this you should be able to run:

在这之后,你应该能够跑:

npm install

#10


1  

It may be very evident,
but try to launch CMD (for Windows) from the project folder, where your package.json file is located.

这可能是非常明显的,但是尝试从项目文件夹启动CMD(对于Windows),在那里您的包。json文件所在的位置。

Do not launch CMD from System or from "Search bar" in Win or
move to your project folder with help of cd command and then launch npm start.

不要从系统或“搜索栏”中启动CMD,或者在cd命令的帮助下移动到你的项目文件夹,然后启动npm启动。

#11


1  

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

好的,试着去到home“user@user:~$”(cd + enter键),npm安装-g你的your_module。

#12


1  

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).

我在npm也遇到了类似的问题。问题是我把这个项目放在同一个名字的两个文件夹里。我通过将其中一个文件夹重命名为其他(推荐的外部文件夹)来解决它。

#13


0  

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'

保存错误:没有这样的文件或目录,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.

然后没有出现丢失的文件或目录消息。

#14


0  

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

谢谢你!我也尝试了很多方法。我也在使用windows。这个命令帮助并节省了我的时间:

npm install -g npm@lts

#15


0  

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

我已经运行了npm安装-y,以跳过创建丢失文件包的问题步骤。json,y意味着是的

#16


0  

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

它本身就是这样说的。您的项目中没有json。所以,创建包。json,使用以下步骤:

  1. open command prompt on your project directory
  2. 在您的项目目录上打开命令提示符。
  3. npm init (it will ask you to enter lots of entries like name, version, desc, etc., enter some random values and click enter).
  4. npm init(它将要求您输入许多条目,如名称、版本、desc等,输入一些随机值并单击enter)。
  5. type yes and click enter
  6. 输入yes并单击enter。

Now try again.

现在再试一次。

#17


0  

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

初学者通常尝试使用随机定位的命令。在下载或创建项目之后,您必须进入这个项目。里面文件package.json

cd <path_to_project>
npm install

#18


-1  

Adding -g before the package name worked for me. Looking for documentation to explain why this works..

在包名之前添加-g。寻找文档来解释为什么会这样。

#19


-2  

I was also facing same issue while installing typescript. I just initialized an package.josn file by the following command

在安装typescript时,我也面临着同样的问题。我刚刚初始化了一个包。josn文件由以下命令。

npm init -y

And then i installed my typescript

然后我安装了打字稿。

npm install -g -typescript

http://blossomprogramming.blogspot.com/

http://blossomprogramming.blogspot.com/

#1


23  

I think you forgot to setup the directory for express:

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

express <yourdirectory>

Once you do that you should be able to see a bunch of files, you should then run the command:

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

npm install -d

Regards.

的问候。

#2


70  

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

我将简短而致命。安装-d不会为你工作。这很简单。试一试

$ npm install -g express

#3


58  

I think, npm init will create your missing package.json file. It works for me for the same case.

我认为,npm init将会创建您丢失的包。json文件。对我来说也是一样的。

#4


37  

Follwing the below steps you well get package.json file.

下面的步骤你会得到一个包裹。json文件。

npm --version
npm install express
npm init -y

Link : http://www.codingslover.com/2017/02/npm-node-js-cant-find-packagejson.html

链接:http://www.codingslover.com/2017/02/npm-node-js-cant-find-packagejson.html

#5


15  

If Googling "no such file or directory package.json" sent you here, then you might be using a very old version of Node.js

如果google“没有这样的文件或目录包”。json“发送给您,然后您可能会使用非常旧版本的Node.js。”

The following page has good instructions of how to easily install the latest stable on many Operating systems and distros:

下面的页面很好地说明了如何在许多操作系统和发行版上轻松安装最新的稳定版:

https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager

https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager

#6


6  

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

使用win7/win8/win10 (CD)中的命令来移动文件夹:

  1. Enter your projects folder

    输入您的项目文件夹

  2. Run: npm install -d

    运行:npm安装- d

#7


2  

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

我的问题是我没有一个包裹。出于某种原因,json文件。在我将这个文件放入我的目录之后,我就可以运行npm安装了。

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

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

#8


2  

try re-install Node.js

尝试重新安装node . js

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

curl - sl https://deb.nodesource.com/setup_4.x | sudo - e bash -。

sudo apt-get install -y nodejs

sudo apt-get安装-y nodejs。

sudo apt-get install -y build-essential

and update npm

和更新npm

curl -L https://npmjs.com/install.sh | sudo sh

#9


2  

Node comes with npm installed so you should have a version of npm. However, npm gets updated more frequently than Node does, so you'll want to make sure it's the latest version.

节点是由npm安装的,所以您应该有一个npm版本。但是,npm比Node更频繁地更新,所以您需要确保它是最新版本。

sudo npm install npm -g

Test:

测试:

npm -v //The version should be higher than 2.1.8

After this you should be able to run:

在这之后,你应该能够跑:

npm install

#10


1  

It may be very evident,
but try to launch CMD (for Windows) from the project folder, where your package.json file is located.

这可能是非常明显的,但是尝试从项目文件夹启动CMD(对于Windows),在那里您的包。json文件所在的位置。

Do not launch CMD from System or from "Search bar" in Win or
move to your project folder with help of cd command and then launch npm start.

不要从系统或“搜索栏”中启动CMD,或者在cd命令的帮助下移动到你的项目文件夹,然后启动npm启动。

#11


1  

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

好的,试着去到home“user@user:~$”(cd + enter键),npm安装-g你的your_module。

#12


1  

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).

我在npm也遇到了类似的问题。问题是我把这个项目放在同一个名字的两个文件夹里。我通过将其中一个文件夹重命名为其他(推荐的外部文件夹)来解决它。

#13


0  

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'

保存错误:没有这样的文件或目录,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.

然后没有出现丢失的文件或目录消息。

#14


0  

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

谢谢你!我也尝试了很多方法。我也在使用windows。这个命令帮助并节省了我的时间:

npm install -g npm@lts

#15


0  

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

我已经运行了npm安装-y,以跳过创建丢失文件包的问题步骤。json,y意味着是的

#16


0  

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

它本身就是这样说的。您的项目中没有json。所以,创建包。json,使用以下步骤:

  1. open command prompt on your project directory
  2. 在您的项目目录上打开命令提示符。
  3. npm init (it will ask you to enter lots of entries like name, version, desc, etc., enter some random values and click enter).
  4. npm init(它将要求您输入许多条目,如名称、版本、desc等,输入一些随机值并单击enter)。
  5. type yes and click enter
  6. 输入yes并单击enter。

Now try again.

现在再试一次。

#17


0  

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

初学者通常尝试使用随机定位的命令。在下载或创建项目之后,您必须进入这个项目。里面文件package.json

cd <path_to_project>
npm install

#18


-1  

Adding -g before the package name worked for me. Looking for documentation to explain why this works..

在包名之前添加-g。寻找文档来解释为什么会这样。

#19


-2  

I was also facing same issue while installing typescript. I just initialized an package.josn file by the following command

在安装typescript时,我也面临着同样的问题。我刚刚初始化了一个包。josn文件由以下命令。

npm init -y

And then i installed my typescript

然后我安装了打字稿。

npm install -g -typescript

http://blossomprogramming.blogspot.com/

http://blossomprogramming.blogspot.com/