As they say you have several forms, those discussed above and another. I'm going to make a small guide to install the software, check the versions and run a script.
INSTALLING NODE AND NPM
Keep in mind that for a script that uses npm libraries to work, you have to have:
CHECK NODE AND NPM VERSIONS
Once installed, we can check the version we have:
From node:
node -v
From npm:
npm -v
For example, I have:
EXECUTE NODEJS SCRIPT
There are 3 ways to run a node script via terminal.
1. Run via npm start telling you which file:
npm start index.js
2. Define the package.json
field in the script
file:
"scripts": {
"start": "node index.js"
}
And run with:
npm start
3. Run the script via the node command:
node fichero.js
Specifically, in the case of the yagop API it would be:
node index.js