How do I install an NPM package
Use npm to install or update required packages, just like bundlers for Rubygems
I love Bundler, it's great at dependency management. I love npm, node packages installation is easy! I have a NodeJS app and would like to specify my apps dependencies and be able to easily install / update them, wherever I provide my app. This is not a library that I publish, but a full-fledged web app.
I know the command but that just seems to overwrite the directory where packages are installed.
I'm used to using Bundler this way:
Installs Rails v3.0.3 and other required gems on the host computer only if they don't already exist
How can I achieve something similar with npm?
As of npm 1.0 (which is what you now get by default if you follow the steps in the README file), "Bundle" is no longer a separate thing - it's just "How it works".
- Put a file in the root directory of your project
List your deps in this file
Since you are calling this with no arguments and not in global mode, only all of your deps will be installed locally.
- and be happy.
Edit: This only applies to npm versions <1.0
It was pretty difficult to find out, however NPM makes this possible .
You need three components
- A subdirectory in your repository (ie)
- A file in the directory above that lists dependencies
- A file in the directory above that requires your dependencies
Imagine that Express is your only addiction
deps / package.json
Note: Increase the version number every time you change the dependencies
deps / index.js
Now you should be able to install your dependencies using npm. You can even include this part in your deployment process
Then you can access your specific Express version in your app code as follows:
You should read these two articles from the Isaacs blog (author npm). I think they are really good and I think they are saying how to achieve your goal:
I believe link # 1 (item # 11) explains this:
When you use the npm bundle command, npm places all of your dependencies in the node_modules folder in your package. But it doesn't stop there.
If you want to rely on something that is not in the registry, you can. Just do that:
Installation of the npm bundle Installation of the http://github.com/whoever/whatever/tarball/master This will install the content of this tarball in the bundle. You can then list it as a dependency and not try to install it when your package is being installed.
This is also handy if you have your own fork and would rather not change the name.
In fact, you can run almost every npm command in the bundle. To see what's inside you can run the npm bundle ls. To remove something, do npm bundle rm thing. Of course, you can install multiple versions and activate the one you want.
It seems to me that the simplest solution is to use a file with its flag (added to npm just last month) set. This allows you to run or get your project's dependencies, but it prevents someone from accidentally publishing your private project.
Here is an example :
Running is installed on the local system if it does not already exist. Running gives an error because of that.
You and your team can use the version tag internally to track dependency changes over time. Every time you change a dependency, you trigger the version. Use to see which version you have installed.
Publish your app with and list the dependencies in your package.json file.
When someone installs your package, they take care of resolving their dependencies.
Package specification: http://wiki.commonjs.org/wiki/Packages/1.0
- Dogs stay stoned longer than humans
- Why does ice stick on your finger
- Hospitals for treatment of spinal fusion
- What is government power
- What are the best adjustable weight benches
- What is the function of the moth
- What is the function of trichocysts
- How betting sites calculate their chances of winning
- What's your rating of Morgan Stanley
- How do I carry out usability tests efficiently
- How do VMware snapshots work
- Is Nicolas Sarkozy a good speaker
- Is GenPact a good company
- People bully others out of jealousy
- What is 100 100 100 100 9
- How do I download Minecraft Earth
- What are the latest Android application trends
- What do Americans think of Scandinavians?
- What is the difference between hate and regret
- What are the reasons for the wear and tear on employees
- Are other animals gifted than humans
- Is the field excitation identical to the atomic excitation
- Which gun has the coolest name
- A dolphin is a mammal