01 NVM:
NVM is the acronym for Node Version Manager, which is a command-line tool that lets you install and use many Node.js versions and NPM on your computer. It is a dev tool, so I don't recommend using it in production environments. NVM works fine in Linux and Mac. You can also check the documentation here: https://github.com/nvm-sh/nvm.
When is it useful to use NVM?
* In teams where we have different operating systems.
* When we have to test new things, for example, the testing version for Node.js.
* When we have many projects with different versions, and you cannot update Node.js and you have to maintain two or more node js versions in many projects, so is a way to tidy up the dev environment, switching between Node.js versions.
NVM: Installation
Mac:
You can use homebrew. If you don’t know how to install it, you could check here it (https://brew.sh/) and that’s all.
Linux:
The line before will have an output such as this:
Make sure that these lines below are in your ~/.bashrc or ~/.zshrc:
My personal desktop runs over Arch Linux, so I used an aur package, for example https://aur.archlinux.org/packages/nvm/. I downloaded the snapshot file and uncompressed the tar.gz file. Also, you could use the same installation explained before or these lines for installing nvm:
NVM Usage:
nvm list : List all versions installed on your machine
NVM install: Install a local version on your machine from the remote list. The remote list could be filtered by another command like: nvm ls-remote <versionLike> for example “nvm ls-remote v11” lists all versions that have v11 as prefix.
nvm use: set in the current terminal the environments variables so all command executed related to Node.js will use the version defined by NVM.
nvm which: show the path to the Node.js bin file.
02 Docker container with node js/ angular-cli:
Hub docker contains a thousand images that you could use in your daily tasks at work, in a simple search you could see (https://hub.docker.com/search?q=angular-cli&type=image)
About 1 - 25 of 492 results for angular-cli.
Here is my recommendation to use it in a local environment for a development process: https://hub.docker.com/r/trion/ng-cli/
When node_modules directory already was generated.
In this way, you need node_modules directory inside the directory defined in $PWD variable.
When a node_modules directory is not generated. And that’s all.
first
later:
03 Dotenv using a .env file with and avoid versioning
Dotenv is useful to keep tidy up the code, avoid magic number, avoid push any secret key to the repo and it is a relief for many environments. With this, you can run your app anywhere by modifying the environment variables without changing your code and without rebuilding it!
Later, create the .env file in the root of your app and add your variables and values to it. Don’t forget to add this file to .gitignore to avoid committing it.
4 Cloud solutions:
For each project, you could use one of these, sometimes I have to share code with a friend or when I have a doubt, and I need to ask something with a context code, it’s the best way to show when you are remote, for example for an angular-cli project there is no doubt that the best is https://stackblitz.com/ has a better integration with angular and let you download the project in a zip file, also is recommended by @angular documentation.
Also for Js, HTML, and CSS, and tiny projects you could use https://jsfiddle.net/, https://codepen.io/. In the last one, there are many web artists and you could make you own portfolio to share it. And From Red Hat, we have https://codenvy.com/ has a free subscription with limitations, but it’s ok for prototyping things.