当前位置: 首页 > 后端技术 > Node.js

npm总结

时间:2023-04-03 11:16:57 Node.js

npm是顺序&并行执行脚本,没有上下文关系,即同时并行执行。但是cmd.exe(npmrun-script在win上默认使用它)不支持&。&&后续执行,上一个任务执行成功才继续下一个任务。官方的npmrun-script命令是不能同时运行多个脚本的,所以如果我们想运行多个脚本,可以参考下面的写法(虽然写法好像有点多余):npmrunclean&&npmrunbuild:css&&npmrunbuild:js&&npmrunbuild:html建议使用npm-run-all包。解决上面提到的跨平台和简化编写问题。#依次执行npm-run-alllintbuild#并行执行npm-run-all--parallellintbuildnrmNRM可以帮助您方便快捷地在不同的NPMregistry之间切换,现在包括:NPM、cnpm、淘宝、nj(nodejitsu).类似于执行npxcreate-react-appxxx,如果不换国内源,会浪费很多时间。npx调用项目安装的npm包的二进制模块。npxmocha--version避免安装全局模块最常见的是脚手架创建项目,但是不需要全局安装npxcreate-next-app@latest使用不同版本的node执行github源码#执行Gist代码npxhttps://gist.github.com/zkat/4bc19503fe9e9309e2bfaa2c58074d32#执行仓库代码npxgithub:piuccio/cowsayhello参考文章npmscripts使用指南npx