{"id":159,"date":"2020-10-01T19:38:00","date_gmt":"2020-10-01T19:38:00","guid":{"rendered":"https:\/\/molecularsciences.org\/content\/?p=159"},"modified":"2024-02-08T08:20:03","modified_gmt":"2024-02-08T13:20:03","slug":"node-package-manager-npm","status":"publish","type":"post","link":"https:\/\/molecularsciences.org\/content\/node-package-manager-npm\/","title":{"rendered":"Node Package Manager (npm)"},"content":{"rendered":"\n<p>Node Package Manager (npm) comes bundled with Node. It allows you do search Node repositories for packages and modules. Anything that is searchable on search.nodejs.org is also searchable by npm. npm can be used to install Node packages on your system. It also performs version and dependency management for all Node packages installing on your system. To find out the version of npm you are using, simply type the following command<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ npm --version\n3.10.6<\/code><\/pre>\n\n\n\n<p>To upgrade you npm,<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo npm install npm -g\n\/usr\/local\/bin\/npm -&gt; \/usr\/local\/lib\/node_modules\/npm\/bin\/npm-cli.js\nnpm@3.10.6 \/usr\/local\/lib\/node_modules\/npm\n$ npm --version\n3.10.6<\/code><\/pre>\n\n\n\n<p>To install a module<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ npm install express<\/code><\/pre>\n\n\n\n<p>where express is a module. Express.js is now installed in the local Node repository. To use it, you will need to require it as follows:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>var ex = require(\u2018express\u2019);<\/code><\/pre>\n\n\n\n<p>To list all installed modules<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ npm ls<\/code><\/pre>\n\n\n\n<p>To uninstall a module<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ npm uninstall express<\/code><\/pre>\n\n\n\n<p>By default all modules are installed locally. They are only visible in the directory and subdirectories or the directory you were in when you ran npm install. To make the a module visible globally (to all applications in your system), you need to install it globally as follows:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo npm install express -g<\/code><\/pre>\n\n\n\n<p>This will install the module to \/usr\/local\/lib or some other global location. To view globally installed modules<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ npm ls -g<\/code><\/pre>\n\n\n\n<p>To update a module<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ npm update express<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Node Package Manager (npm) comes bundled with Node. It allows you do search Node repositories for packages and modules. Anything that is searchable on search.nodejs.org is also searchable by npm. npm can be used to install Node packages on your system. It also performs version and dependency management for all Node packages installing on your [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":541,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[512],"tags":[72,61],"class_list":["post-159","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-misc","tag-node-js","tag-npm"],"_links":{"self":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/159","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/comments?post=159"}],"version-history":[{"count":2,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/159\/revisions"}],"predecessor-version":[{"id":542,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/159\/revisions\/542"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/media\/541"}],"wp:attachment":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/media?parent=159"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/categories?post=159"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/tags?post=159"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}