To remind myself for all eternity how to add node.js to a project that will live remotely on a server, and not able to access the version of node.js that’s on my local computer.
What is node.js?
Why do I need it for my project?
I also need node.js inside my local project because it’s going to live on a remote server, without access to my globally installed node.js on my computer.
How do I add Node.js to a local project?
I’ll use npm (or “node packaged models”) as a tool to install node.js into my local project. npm can install the node.js packages I need in local or global mode. In local mode it will install packages in a node_modules folder in my project’s parent working directory.
Use this npm webpage to find the latest commands.
But generally all I need to do is inside my project’s working directory in terminal, use $ npm install node.js ($ npm install <package_name>).
One extra step
How do I check for updates?
Check NPM’s webpage here for the latest commands. Generally, first check that I have node and npm installed. To check if you have Node.js installed, run this command in your terminal.
Note: This command checks whether node.js exists globally on your machine, not whether a copy is saved in your project folder that will exist on a remote server. I need both.
To confirm that you have npm installed you can run this command in your terminal:
npm is a separate project and updates more regularly, so update your npm. To update your npm, type this into your terminal:
npm install npm@latest -g
How do I make sure I’m using a LTS version of Node.js ?
Not sure yet.
Should I use a Node.js version manager?
Is there a way to switch between versions of node and npm?
How do I switch my project over to run forever?
Full instructions here.
Type $ npm install forever -g
Then type forever start app.js