For starters u can just send a message
script npm install <package> . For more advanced use-cases we recommend using a
package.json file to maintain your project's dependencies, their versions etc. More info can be found here:
https://docs.npmjs.com/files/package.json But the basic principle is, create a package.json file (minimal info is fine) next to the js script you are referencing
{
"name": "my-n4m-project",
"version": "0.1.0",
"dependencies": {
}
}
Form there one sending any npm commands to the node.script object will act similar to running anything from the CLI. So for example npm install tonal will install the tonal package and add it as a dependency entry to your package.json.
Please note that it's not necessary to have a system wide Node installation on your machine (as shown in the video Sam linked to) as Node For Max bundles it's own Node and NPM versions and as long as you operate it from the patch things should "just work" as if you were running them from the CLI.