First experiences with node.js/npm. From the npm-install docs I read:
npm install
takes 3 exclusive, optional flags which save or update the package version in your main package.json
:
--save
: Package will appear in your dependencies
.
--save-dev
: Package will appear in your devDependencies
.
--save-optional
: Package will appear in your optionalDependencies
.
But I can't understand how it works in practice. If, for example, I run the command:
npm install bower --save-dev
I'd expect to find a package.json
file in the current directory with devDependencies
set to the installed version of bower, instead I find nothing.
Am I doing/expecting something wrong?
Using node v0.10.21, npm 1.3.12 on Ubuntu 12.04 x64
npm
won't create package.json
for you, but it will create the necessary dependencies for you as long as package.json
exists and is legal JSON.
Create it like so
echo {} > package.json
Then, doing npm i --save whatever
will add whatever@~x.x.x
as a dependency as expected. The file needs to be there, and be JSON, that's it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With