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

时间:2019-03-12 19:17:07   收藏:0   阅读:169

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

 

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

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!