NodeJS: Difference between revisions

390 bytes added ,  26 August 2019
no edit summary
No edit summary
No edit summary
Line 1: Line 1:
Node.js is a JavaScript environment based on Chrome's V8 JavaScript engine.
Node.js is a JavaScript environment based on Chrome's V8 JavaScript engine.
Node Package Manager (npm) is used to manager node packages installed on your computer or used in your node projects.
Node Package Manager (npm) is used to manage node packages installed on your computer or used in your node projects.<br>
An alternative to npm is yarn.


==Installation==
==Installation==
Line 25: Line 24:
<code>npm install</code> installs the latest dependencies listed in <code>package.json</code> subject to the requirements listed in that file. It also updates <code>package-lock.json</code>.<br>
<code>npm install</code> installs the latest dependencies listed in <code>package.json</code> subject to the requirements listed in that file. It also updates <code>package-lock.json</code>.<br>
<code>npm ci</code> installs exact versions from the <code>package-lock.json</code>.
<code>npm ci</code> installs exact versions from the <code>package-lock.json</code>.
===Yarn===
[https://yarnpkg.com/en/ Yarn] is an alternative to npm. It caches packages on disk to speed up installs.
While you can migrate from npm to yarn, it is recommended to stick to a single package manager since they each use their own lockfile.
===pnpm===
[https://pnpm.js.org pnpm] uses symlinks to a single copy of each dependency to save disk space.
pnpm uses its own lockfile instead of packages-lock.json.


==Useful Packages==
==Useful Packages==
===fs-extra===
===fs-extra===
[https://www.npmjs.com/package/fs-extra fs-extra] adds additional commands for accessing the filesystem such as copying and moving files.
[https://www.npmjs.com/package/fs-extra fs-extra] adds additional commands for accessing the filesystem such as copying and moving files.