博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[Whole Web] [Node.js] Using npm run to launch local scripts
阅读量:6991 次
发布时间:2019-06-27

本文共 1428 字,大约阅读时间需要 4 分钟。

npm run allows you to configure scripts inside of your package.json file which can access locally installed node packages. If you're comfortable with this technique, you can also grunt, gulp, or other build tools by customizing your scripts and saving them inside of your package.json file. With this approach, when a developer starts a new project with your package.json, they can simply runnpm install then npm run yourscript without having to install any node packages globally.

 

For example:

If you haven't installed browserify globally, and you use npm to install it locallly:

npm install browserify --save-dev

 

Then you create a test script to run browserify:

"scripts": {    "test": "echo \"Error: no test specified\" && exit 1",    "demo": "echo Hello World!",    "b_version": "browserify -v"  },

 

You run on tml:

npm run b_version

You will get the version number, but if you type in tml:

browserify -v

You will get error, because you haven't installed it globally, which means that I can use npm run to invoke anything I've installed locally without forcing my users to say "npm install -g" to install things globally, Which means with this approach, you could just include a package file in your project, say "npm install" to get everything installed locally, and then npm run whatever task you want to set up, whether it's browserify or whatever. Then it can just grab those locally installed modules and run them.

 

More: 

 

转载地址:http://nkbvl.baihongyu.com/

你可能感兴趣的文章
Cache.Insert 方法(摘自MSDN)
查看>>
Duck typing
查看>>
每日一记--索引/过滤器
查看>>
Struts2的CRUD操作
查看>>
A Simple Problem with Integers
查看>>
WampServer中MySQL中文乱码解决
查看>>
Codeforces-938D-Buy a Ticket(最短路设虚拟节点+Dijk优先队列优化)
查看>>
电商打折套路分析 —— Python数据分析练习
查看>>
HTTP请求、响应报文格式
查看>>
zendstudio中出现中文乱码的解决方法
查看>>
服务器端与客户端TCP连接入门(一)
查看>>
lombok使用方法
查看>>
多线程基础
查看>>
1028: C语言程序设计教程(第三版)课后习题8.2
查看>>
批量更新软连接脚本
查看>>
Linux 文件和目录的属性
查看>>
Log4j配置使用
查看>>
初步认识Hadoop
查看>>
jQuery对象扩展方法(Extend)深度解析
查看>>
9道前端技能编程题
查看>>