Node: Difference between revisions
From charlesreid1
| (6 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
==installing on debian== | ==installing on debian== | ||
From the nodejs docs, how to install on debian: https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions | |||
<pre> | |||
curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash - | |||
sudo apt-get install -y nodejs | |||
</pre> | |||
==no npm binary found== | |||
If no npm binary is found after running <code>apt-get install nodejs</code>, you probably aren't using the latest up-to-date nodejs package. The curl command above is necessary to update which version of nodejs aptitude is trying to install. | |||
==installing node packages== | |||
I'll use the <code>mongo-express</code> package to illustrate. | |||
There are two ways to install a package: locally, and globally. | |||
Installing a package locally will create a package lock json file and a node modules directory, from which the mongo-express script can be run. To install locally, run: | |||
<pre> | |||
npm install mongo-express | |||
</pre> | |||
Installing a package globally keeps things a little more clean, all files are maintained in /usr/lib/node_modules. To install, add the -g flag: | |||
<pre> | <pre> | ||
npm install -g mongo-express | |||
</pre> | </pre> | ||
==flags== | |||
[[Category:Node.js]] | |||
[[Category:Javascript]] | |||
[[Category:Aptitude]] | |||
Latest revision as of 13:19, 30 January 2018
installing on debian
From the nodejs docs, how to install on debian: https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions
curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash - sudo apt-get install -y nodejs
no npm binary found
If no npm binary is found after running apt-get install nodejs, you probably aren't using the latest up-to-date nodejs package. The curl command above is necessary to update which version of nodejs aptitude is trying to install.
installing node packages
I'll use the mongo-express package to illustrate.
There are two ways to install a package: locally, and globally.
Installing a package locally will create a package lock json file and a node modules directory, from which the mongo-express script can be run. To install locally, run:
npm install mongo-express
Installing a package globally keeps things a little more clean, all files are maintained in /usr/lib/node_modules. To install, add the -g flag:
npm install -g mongo-express