Often times you’ll have variations that you’ll want to make to your npm scripts and repeating yourself is inefficient and verbose. Instead you can create a base script and pass arguments into it from another script.

For example, you have a script:

"test": "mocha spec/ --require babel-register",

And you want to add a watcher to the test script:

"test:watch": "mocha spec/ --require babel-register --watch",

Here what we do is copy the script and add a '--watch' behind. This is not good enough, because if you want to change the 'test' script, you also need to modify the 'test:watch' script.

So what you can do:

"test:watch": "npm t -- --watch"

First '--' tell the compiler that we still need to pass in some arguments; And '--watch' is what we want to pass in.

[NPM] Pass arguments to npm scripts的更多相关文章

  1. 输入npm install 报错npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! node-sass@4.13.1 postinstall: `node scripts/build.js`

    输入npm install 报以下错误 npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! node-sass@4.13.1 postinstall: ...

  2. npm run dev 和 npm run serve

    1.ERR引发的思考 创建好的 vue 项目直接执行 vue run dev 报错?运行 vue run serve 就可以启动...如下 npm run dev npm ERR! missing s ...

  3. 解决npm安装模块时 npm err! registry error parsing json

    最近还真是点背,从yeoman生成一个react项目或是github上克隆一个项目,在npm install的时候, 一直报npm err! registry error parsing json(就 ...

  4. 安装Vue2的devtools发生错误npm ERR! code EINTEGRITY npm ERR! sha1-HTFDXrRzR2Ew8Bv9zlMSCVgPsS0= integrity checksum failed when using sha1: wanted sha1-HTFDXrRzR2Ew8Bv9zlMSCVgPsS0= but got sha1-Z6BeTMF4nhAO6h5A

    1.github下载地址:https://github.com/vuejs/vue-devtools 2.下载好后进入vue-devtools-master工程  执行npm install ---- ...

  5. npm ERR! code EINTEGRITY npm! ERR! shal-

    npm ERR! code EINTEGRITY npm ERR! sha1-nbqdpC/e8IOA7poHctXL5+bVXsE= integrity checksum failed when u ...

  6. npm install出错,npm ERR! code EINTEGRITY npm ERR! Verification failed while extracting url-parse@1.4.3

    npm install时出现以下错误: npm ERR! code EINTEGRITY npm ERR! Verification failed while extracting url-parse ...

  7. npm install报错 npm ERR! enoent ENOENT: no such file or directory

    在npm之后出现如下错误: $ npm install npm WARN checkPermissions Missing write access to /Users/lucas/code/js/v ...

  8. npm ERR! errno 1 npm ERR! chromedriver@2.35.0 install: `node install.js`

    在使用webpack+vue-cli进行vue项目构建时可能会出现一下错误,webpack@3.10.0及以上版本和vue-cli@2.9.2及以上版本会自动安装依赖(我在自己电脑上测试是这样的)不用 ...

  9. vue项目,npm install后,npm run dev报错问题

    报错: ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! metools@1.0.0 dev: `node build/dev-server.js` npm ...

随机推荐

  1. 洛谷 P1223 排队接水

    洛谷 P1223 排队接水 题目描述 有n个人在一个水龙头前排队接水,假如每个人接水的时间为Ti,请编程找出这n个人排队的一种顺序,使得n个人的平均等待时间最小. 输入输出格式 输入格式: 输入文件共 ...

  2. Gmail 收信的一些规则

    Gmail 收信的一些规则 用 apache+php+MDaemon 调试 mail2www 时,发往gmail的邮件失败, 提示: Our system detected an illegal at ...

  3. css实现背景半透明文字不透明的效果

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  4. java线程——三种创建线程的方式

    前言 线程,英文Thread.在java中,创建线程的方式有三种: 1.Thread 2.Runnable 3.Callable 在详细介绍下这几种方式之前,我们先来看下Thread类和Runnabl ...

  5. datagridview合并相同单元格

    private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) { // 对第日 ...

  6. 2015,我的投资理财策略(股权众筹+P2P网贷+活期理财)

    纸币流行,尤其是当今中国的市场经济,纸币几乎是一直是贬值的,每个人的财富都在被不断地稀释,可能是被政府.如果你不注意保值增值,你就越来越穷.     当年的万元户,在今天看来就是一个笑话,其实不怎么好 ...

  7. js实现科学计算机

    js实现科学计算机 一.总结 1.算法:这个科学计算机是用普通基础算法实习的,没有用栈,用栈要简单很多, 2.发现规律,编程分类:编程的时候,运算符分两种,一元运算符和二元运算符,分类了就好写很多了. ...

  8. Seal Report开放数据库报表工具(.Net)

    Seal Report_20160923 概述:开放数据库报表工具(.Net) 简介:Seal-Report提供了一个完整的框架,用于从任何数据库生成日常报告和仪表板.Seal-Report是Micr ...

  9. Hadoop笔记(一)

    1.大数据的概述 大数据:巨量数据.海量数据,首先在数据的量上达到一定的规模,首先是人或者计算机在不合理时间内是不能够实现的数据量. 2.特点:数据量比较大,数据类型多样化.处理速度问题 3.大数据平 ...

  10. 【习题 3-6 UVA - 232】Crossword Answers

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 模拟题.注意场宽为3 [代码] #include <bits/stdc++.h> using namespace std ...