首页 > Web开发 > 详细

[NPM] Use npx to run commands with different Node.js versions

时间:2019-03-12 19:17:07      阅读:168      评论:0      收藏:0      [点我收藏+]

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

 

[NPM] Use npx to run commands with different Node.js versions

原文:https://www.cnblogs.com/Answer1215/p/10518820.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!