NodeJS: Difference between revisions

 
(2 intermediate revisions by the same user not shown)
Line 5: Line 5:
==Installation==
==Installation==
===Linux===
===Linux===
Using the [https://github.com/nvm-sh/nvm Node Version Manager (nvm)] is recommended. This does not require sudo as nvm is installed in your home directory.
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
Line 84: Line 86:
<syntaxhighlight lang="js">
<syntaxhighlight lang="js">
</syntaxhighlight>
</syntaxhighlight>


===Running other processes===
===Running other processes===
Line 141: 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. I usually use this snippet to parse 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 168: 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.