简体   繁体   中英

Can anyone explain me what is the reason behind this behaviour of npm have I not installed the dependencies correctly or is it something else

PS E:\\test> npm install <packagename> --save -dev Says --dev option is depreacated use --only=dev npm WARN install Usage of the --dev option is deprecated. Use --only=dev instead.

When I change my call to npm as shown below

PS E:\\test> npm install <packagename> --only=dev I get the following error

-- (empty) npm ERR! code

How can I debug this and know more about it ??

This is really an interesting situation. Indeed you made a typo. Instead of writing --save-dev you wrote --save -dev . There is already a --dev argument which can be used in order to install only the development dependencies that are defined in your package.json. Probably the parser thinks that you wanted to type --dev instead of -dev so it gives you the deprecation warning. The --dev is deprecated and is replaced by the --only=dev argument. This only works for the entire package.json and not for a specific package. So the npm install <packagename> --only=dev is kind of invalid.

If you need to install a new module and save it devDependencies section in package.json you should use the command:

npm i <packagename> -D
# or:
npm i <packagename> --save-dev # without space

If your devDependencies section is not empty, and you want to install only modules from that section you should use the command:

npm i --only=dev

The --only={prod[uction]|dev[elopment]} argument will cause either only devDependencies or only non-devDependencies to be installed regardless of the NODE_ENV.

You have a space in the option. The correct option is --save-dev , not --save -dev

You will need mention your node and npm versions as when I try this:

npm install bower --save-dev

This works fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM