Reputation: 46613
Tried these:
✗ nvm run 9 npm start
Running node v9.10.1 (npm v5.8.0)
module.js:545
throw err;
^
Error: Cannot find module '/Users/foo/work/grid-styled/npm'
at Function.Module._resolveFilename (module.js:543:15)
✗ nvm run 9 npm -- x0 dev docs/App.js
Running node v9.10.1 (npm v5.8.0)
module.js:545
throw err;
^
Error: Cannot find module '/Users/foo/work/grid-styled/npm'
I can get it to run by calling the bin directly:
nvm run 9 node_modules/.bin/x0 dev docs/App.js
But it would be better to just call npm. Seems possible but the nvm docs don't address this use case.
Upvotes: 12
Views: 16053
Reputation: 3477
If you use nvm run
you are executing node on a specific version, so:
nvm run 9 npm start
is equivalent to node npm start
(with version 9 of node). That's the reason for the error.
You should use nvm exec
instead, that is for executing a command on specific version, for instance:
$ nvm exec 10 npm -v
Running node v10.0.0 (npm v6.0.0)
6.0.0
$ nvm exec 6 npm -v
Running node v6.10.3 (npm v3.10.10)
3.10.10
Upvotes: 22