We will use npx to run a package using different versions of Node.js. This can become valuable when testing the various new features that are introduced in versions of Node.js.
For example this code:
let a = { one: , two: }; console.log( { ...a, three: } );
If we run this code with node@8.2.1, because version 8.2.1 did not yet have support for object spread
. It makes sense why we would get an unexpected token error at the ...a
location.
We can ask NPX to run with a different node version:
npx -p node@8.3. -- node index.js