在 npm 脚本中运行 2 个命令(nodemon && sass --watch) [英] Running 2 commands in npm script(nodemon && sass --watch)

查看:63
本文介绍了在 npm 脚本中运行 2 个命令(nodemon && sass --watch)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个看起来像这样的 package.json 文件.

I have a package.json file looks like this.

我想知道为什么我不能运行这两个命令:

"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" },

"both": "nodemon src/app.js -e js,hbs && sass --watch public/scss:public/css"

I wonder why I cannot run these 2 commands:

by

当我尝试运行它时,只有第一个命令有效.

npm run both

Github 存储库在下面,以防万一您需要进行一些测试.

When I try to run it, only the first command is working.

https://github.com/tuanphanfi/weather-app-nodejs/

推荐答案

使用名为 concurrently 的包

解决方案

一>.

npm install concurrently

然后你可以制作一个名为both

Then you can make a script called both

"both": "concurrently \"nodemon src/app.js -e js,hbs\" \"sass --watch public/scss:public/css\""

请参阅 javascript - 如何在其中运行多个 npm 脚本平行?

这篇关于在 npm 脚本中运行 2 个命令(nodemon && sass --watch)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆