node.js - 在 npm 脚本中运行 2 个命令(nodemon && sass --watch)
问题描述
我有一个 package.json 文件,看起来像这样。
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node src/app.js",
"dev": "nodemon src/app.js -e js,hbs ",
"scss": "sass --watch public/scss:public/css",
"both": "nodemon src/app.js -e js,hbs && sass --watch public/scss:public/css",
"both2" : "npm run dev && npm run scss"
},
我想知道为什么我不能运行这两个命令:
“两者”:“nodemon src/app.js -e js,hbs && sass --watch public/scss:public/css”
经过
npm run both
当我尝试运行它时,只有第一个命令有效。
Github 存储库在下面,以防万一您需要一些测试。
解决方案
使用一个名为concurrent的包。
npm install concurrently
然后你可以制作一个名为both
"both": "concurrently \"nodemon src/app.js -e js,hbs\" \"sass --watch public/scss:public/css\""
推荐阅读
- angular - 角组件输入总是返回未定义
- ios - Metal:写入纹理并读取它而不调用 endEncoding
- sql - 我需要根据关键字查询数据库
- flutter - 我应该把开始运行一次的命令放在哪里?
- event-handling - Eclipse Rcp - 是否有推荐的方法来获取在处理程序中调用事件的父视图或编辑器?
- java - 使用多个正则表达式:按显示顺序一次打印一个匹配项
- amazon-web-services - 如何从 Lambda 中的警报事件中提取特定信息
- excel - 如何从雅虎财经下载限制为 100 行的数据
- javascript - JavaScript - 在另一个函数之外返回函数值
- winforms - Winform应用程序在某些变量包含数据后将数据添加到列表视图