[英]Warnings when installing npm modules in project directories, but not when installing globally
I have observed this issue when installing both newsapi and RequireJS.我在安装 newsapi 和 RequireJS 时发现了这个问题。 The path to my project directory is as follow: Users\\username\\project
我的项目目录路径如下: Users\\username\\project
In my project directory, when I run npm install newsapi --save
(installation instructions per the newsapi site or npm install requirejs
(installation instructions per the RequireJS site , I get the following identical warnings:在我的项目目录中,当我运行npm install newsapi --save
(根据newsapi 站点的安装说明或npm install requirejs
(根据RequireJS 站点的安装说明)时,我收到以下相同的警告:
npm WARN saveError ENOENT: no such file or directory, open 'C:\Users\username\project\package.json'
npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\username\project\package.json'
npm WARN project No description
npm WARN project No repository field.
npm WARN project No README data
npm WARN project No license field.
It may be worth noting the project\\node_modules\\newsapi
and project\\node_modules\\requirejs
are still created and they seems to be populated as they should.可能值得注意的是project\\node_modules\\newsapi
和project\\node_modules\\requirejs
仍然被创建,并且它们似乎被填充。
I noticed that when I install the modules globally (by running npm install -g newsapi --save
or npm install -g requirejs
) the installation succeeds without displaying any warnings.我注意到当我全局安装模块时(通过运行npm install -g newsapi --save
或npm install -g requirejs
)安装成功而没有显示任何警告。 Why is this the case?为什么会这样? What is happening in my project folder that might be causing this issue?我的项目文件夹中发生了什么可能导致此问题?
npm install fhqhwhgads
will try to update the local project package.json
but npm install -g fhqwhgads
will install globally and so there's no package.json
to update. npm install fhqhwhgads
将尝试更新本地项目package.json
但npm install -g fhqwhgads
将全局安装,因此没有package.json
可以更新。 So that's why you're note getting an warning with global installation.这就是为什么您会注意到在全局安装时收到警告的原因。
If you want to create a package.json
so that your dependencies can be tracked and replicated by others (or if you want to publish your code as a package), you can use npm init
.如果你想创建一个package.json
以便你的依赖项可以被其他人跟踪和复制(或者如果你想将你的代码作为一个包发布),你可以使用npm init
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.