npm WARN enoent ENOENT:没有这样的文件或目录,打开'C:\ Users \ Nuwanst \ package.json'

时间:2021-02-11 19:32:11

I just want to install socket.io to my project which is located on 3.chat folder. But when I run following command it shows following Warnings.And its not created a node_modules directory inside my project folder. How to fix this?

我只想将socket.io安装到我的项目,该项目位于3.chat文件夹中。但是,当我运行以下命令时,它会显示以下警告。它没有在我的项目文件夹中创建一个node_modules目录。如何解决这个问题?

C:\Users\Nuwanst\Documents\NodeJS\3.chat>npm install socket.io
C:\Users\Nuwanst
`-- socket.io@2.0.3

npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\Nuwanst\package.json'
npm WARN Nuwanst No description
npm WARN Nuwanst No repository field.
npm WARN Nuwanst No README data
npm WARN Nuwanst No license field.

3 个解决方案

#1


17  

Have you created a package.json file? Maybe run this command first again.

你创建了一个package.json文件吗?也许再次运行此命令。

C:\Users\Nuwanst\Documents\NodeJS\3.chat>npm init

It creates a package.json file in your folder.

它会在您的文件夹中创建一个package.json文件。

Then run,

C:\Users\Nuwanst\Documents\NodeJS\3.chat>npm install socket.io --save

C:\ Users \ Nuwanst \ Documents \ NodeJS \ 3.chat> npm install socket.io --save

The "--save" ensures your module is saved as a dependency in your package.json file.

“--save”确保您的模块在package.json文件中保存为依赖项。

Let me know if this works.

让我知道这个是否奏效。

#2


2  

You need to make sure if package.json file exist in app folder. i run into same problem differently but solution would be same

您需要确保app.file文件中是否存在package.json文件。我遇到的问题不同,但解决方案是一样的

Run this command where "package.json" file exist. even i experience similar problem then i change the folder and got resolve it. for more explanation i run c:\selfPractice> npm start whereas my package.json resides in c:\selfPractice\frontend> then i change the folder and run c:\selfPractice\frontend> npm start and it got run

运行此命令,其中存在“package.json”文件。即使我遇到类似的问题,然后我更改文件夹并解决它。为了更多的解释我运行c:\ selfPractice> npm start而我的package.json位于c:\ selfPractice \ frontend>然后我更改文件夹并运行c:\ selfPractice \ frontend> npm start并运行

#3


0  

If you already have package-lock.json file just delete it and try again.

如果您已经有package-lock.json文件,请将其删除并重试。

#1


17  

Have you created a package.json file? Maybe run this command first again.

你创建了一个package.json文件吗?也许再次运行此命令。

C:\Users\Nuwanst\Documents\NodeJS\3.chat>npm init

It creates a package.json file in your folder.

它会在您的文件夹中创建一个package.json文件。

Then run,

C:\Users\Nuwanst\Documents\NodeJS\3.chat>npm install socket.io --save

C:\ Users \ Nuwanst \ Documents \ NodeJS \ 3.chat> npm install socket.io --save

The "--save" ensures your module is saved as a dependency in your package.json file.

“--save”确保您的模块在package.json文件中保存为依赖项。

Let me know if this works.

让我知道这个是否奏效。

#2


2  

You need to make sure if package.json file exist in app folder. i run into same problem differently but solution would be same

您需要确保app.file文件中是否存在package.json文件。我遇到的问题不同,但解决方案是一样的

Run this command where "package.json" file exist. even i experience similar problem then i change the folder and got resolve it. for more explanation i run c:\selfPractice> npm start whereas my package.json resides in c:\selfPractice\frontend> then i change the folder and run c:\selfPractice\frontend> npm start and it got run

运行此命令,其中存在“package.json”文件。即使我遇到类似的问题,然后我更改文件夹并解决它。为了更多的解释我运行c:\ selfPractice> npm start而我的package.json位于c:\ selfPractice \ frontend>然后我更改文件夹并运行c:\ selfPractice \ frontend> npm start并运行

#3


0  

If you already have package-lock.json file just delete it and try again.

如果您已经有package-lock.json文件,请将其删除并重试。