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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/45531633/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 03:05:13  来源:igfitidea点击:

npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\Nuwanst\package.json'

javascriptnode.jsnpmservernode-modules

提问by Clive Mac

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.chat>npm install socket.io
C:\Users\Nuwanst
`-- [email protected]

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.

回答by Aravin

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

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

回答by Clive Mac

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

您是否创建了package.json文件?也许再次运行此命令。

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

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

It creates a package.jsonfile 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 --saveensures your module is saved as a dependency in your package.jsonfile.

--save确保您的模块保存为您的依赖关系的package.json文件。

Let me know if this works.

让我知道这个是否奏效。

回答by Akitha_MJ

Delete package-lock.jsonit works for me

删除 package-lock.json它对我有用

then npm install

然后 npm install

回答by Rajesh Kumar Bhawsar

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 文件夹中是否存在 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 并运行

回答by AAAmresh 007

finally, I got a solution if you are getting:-

最后,如果您遇到以下问题,我得到了解决方案:-

**npm WARN tar ENOENT: no such file or directory,.......**

then it is no issue of npm or its version it is os permission issue to resolve this you need to use below command:-

那么这不是 npm 或其版本的问题,它是 os 权限问题来解决此问题,您需要使用以下命令:-

sudo chown -R $USER:$USER *

additional

额外的

sudo chmod -R 777 *

then run:-

然后运行:-

sudo npm i 

回答by John Fouhy

I had this in a new project on Windows. npm installhad created a node_modulesfolder for me, but it had somehow created the folder without giving me full control over it. I gave myself full control over node_modulesand node_modules\.stagingand it worked after that.

我在 Windows 上的一个新项目中有这个。为我npm install创建了一个node_modules文件夹,但它以某种方式创建了该文件夹,而没有让我完全控制它。我让自己完全控制node_modulesnode_modules\.staging然后它就起作用了。

回答by Parth Devloper

If your folder already have package.json

如果您的文件夹已经有 package.json

Then,

然后,

Copy the path of package.json

复制路径 package.json

Open terminal

打开终端

Write:

写:

cd your_path_to_package.json

cd your_path_to_package.json

Press ENTER

ENTER

Then Write:

然后写:

npm install

npm install

This worked for me

这对我有用

回答by abulkhair

if your node_modules got installed in say /home/UserName/ like in my case, your package-lock.json file will also be there. just delete this file, go back to your app folder and run npm initand then npm install <pkgname>(e.g express) and a new node_modules folder will be created for your.

如果您的 node_modules 安装在 /home/UserName/ 中,就像在我的情况下一样,您的 package-lock.json 文件也将在那里。只需删除此文件,返回您的应用程序文件夹并运行npm init,然后npm install <pkgname>(例如 express)将为您创建一个新的 node_modules 文件夹。

回答by niks

we need to create package.jsonby entering npm initand enter package name as package.jsonand optionally fill other requirements else press enter and at last enter yesto confirm. Great!! Now install any npm package without any error.

我们需要通过输入并输入包名称作为package.json来创建package.json并可选择填写其他要求,否则按 Enter 并最后输入yes确认。伟大的!!现在安装任何 npm 包,没有任何错误。npm init

npm install <package_name>

Windows10

视窗10