[英]Why does “npm install <directory>” ignore devDependencies?
I have the following package.json in a directory ~/dirA: 我在〜/ dirA目录中有以下package.json:
{
"name": "dirA",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"vue": "^2.1.8"
},
"devDependencies": {
"vue-loader": "^10.0.2"
}
}
Then I cd to ~/dirB and run npm install ../dirA
so that the node_modules directory gets created in dirB. 然后我cd到〜/ dirB并运行
npm install ../dirA
以便在dirB中创建node_modules目录。
The problem is that it does not install the devDependencies. 问题是它没有安装devDependencies。 My NODE_ENV environment variable is not set.
我的NODE_ENV环境变量未设置。
I just get this output: 我刚得到以下输出:
[~/dirB]$ npm install ../dirA
/home/tbeadle/dirB
`-- dirA@1.0.0
`-- vue@2.1.8
npm WARN enoent ENOENT: no such file or directory, open '/home/tbeadle/dirB/package.json'
npm WARN dirB No description
npm WARN dirB No repository field.
npm WARN dirB No README data
npm WARN dirB No license field.
I can even use npm install --only=dev ../dirB
and it continues to ignore the devDependencies I have defined in the package.json. 我什至可以使用
npm install --only=dev ../dirB
,它继续忽略我在package.json中定义的devDependencies。
Any idea on how I can get these devDependencies installed? 关于如何安装这些devDependencies的任何想法吗?
npm install <directory>
does not do what you are trying to do. 不执行您要尝试执行的操作。 According to the docs here ,
根据此处的文档,
npm install :
npm安装:
Install a package that is sitting in a folder on the filesystem.
安装位于文件系统上的文件夹中的软件包。
Also as the console warn suggests, the npm install needs to run where package.json is present. 另外,正如控制台警告所建议的那样,npm安装需要在存在package.json的地方运行。 To install to dirA from dirB, do this:
要从dirB安装到dirA,请执行以下操作:
cd dirB
mkdir -p ../dirA/node_modules
npm install --prefix path_to_folder_in_dirA
Check this stackoverflow question 检查这个stackoverflow问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.