Installing npm packages
There are two ways to install npm packages
- If you want to depend on the package from your own module using something like node.js require, then you want to install locally, which is npm install's default behavior
- If you want to use it as a command line tool, something like the grunt CLI, then you want to install it globally
1. Locally
- This will create the node_modules directory in your current directory and will download the package to that directory
1_1. Example
1_2. Using the installed package
Once the package is in node_modules, you can use it in your code.
it you are creating a Node.js module, you can require it
- Run the code using node index.js It should output [2, 3]
2. Globally
'Tools > npm' 카테고리의 다른 글
[npm] Using a package.json (0) | 2016.06.21 |
---|---|
[npm] 1. What is NPM? (0) | 2016.02.23 |