[NPM] Use npx to run commands with different Node.js versions
2023-09-14 09:00:49 时间
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: 1, two: 2 }; console.log( { ...a, three: 3 } );
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.1 -- node index.js
相关文章
- 初探和实现websocket心跳重连(npm: websocket-heartbeat-js)
- 【nodejs原理&源码赏析(7)】【译】Node.js中的事件循环,定时器和process.nextTick
- 纯js实现复制到剪贴板功能
- MyEclipse设置不编译js部分
- 9.Node.js 包管理器npm
- [Node.js] Using npm link to use node modules that are "in progress"
- C#后台执行js
- [Whole Web] [Node.js] Using npm run to launch local scripts
- [Node.js] Using npm link to use node modules that are "in progress"
- [Node.js] npm init && npm install
- [FE] nvm-windows: Microsoft/NPM/Google 推荐 Windows 的 Node.js 版本管理器
- JS 包管理工具:npm和yarn的区别,我们该如何选择?
- Node.js:npm管理包版本version
- Node.js:使用nrm来管理npm源
- js粘贴事件paste简单解析及遇到的坑
- js之数码时钟加随机变色
- windows下搭建node.js及npm的工作环境