NodeJS: Difference between revisions
No edit summary |
|||
| (5 intermediate revisions by the same user not shown) | |||
| Line 4: | Line 4: | ||
==Installation== | ==Installation== | ||
===Linux=== | ===Linux=== | ||
Using the [https://github.com/nvm-sh/nvm Node Version Manager (nvm)] is recommended. This | Using the [https://github.com/nvm-sh/nvm Node Version Manager (nvm)] is recommended.<br> | ||
You should never use sudo when using npm. Doing so could lead to permission issues. | This installs nvm in your home directory. | ||
You should never use sudo when using nvm or npm. | |||
Doing so could lead to permission issues. | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash | curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash | ||
source ~/.bashrc | source ~/.bashrc | ||
nvm install --lts node | nvm install --lts node | ||
nvm install-latest-npm | nvm install-latest-npm | ||
</syntaxhighlight> | |||
===Windows=== | |||
You can [https://nodejs.org/en/ install node directly] or use [https://github.com/coreybutler/nvm-windows nvm-windows].<br> | |||
Note that nvm-windows is not a port of nvm. | |||
<syntaxhighlight lang="bash"> | |||
choco install nvm | |||
nvm install lts | |||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 80: | Line 86: | ||
<syntaxhighlight lang="js"> | <syntaxhighlight lang="js"> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
===Running other processes=== | ===Running other processes=== | ||
| Line 137: | Line 142: | ||
[https://www.npmjs.com/package/argparse argparse] | [https://www.npmjs.com/package/argparse argparse] | ||
This is a port of python's argparse. However, it does not support configuration files. | This is a port of python's argparse. However, it does not support configuration files. | ||
{{hidden | Example | | |||
<syntaxhighlight lang="python"> | <syntaxhighlight lang="python"> | ||
const parser = new ArgumentParser({ | const parser = new ArgumentParser({ | ||
| Line 164: | Line 170: | ||
})(); | })(); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
}} | |||
===node-worker-threads-pool=== | ===node-worker-threads-pool=== | ||
[https://www.npmjs.com/package/node-worker-threads-pool Link] | [https://www.npmjs.com/package/node-worker-threads-pool Link] | ||
A cool thread pool implementation. | A cool thread pool implementation. | ||