执行package.json脚本

时间:2020-10-03 15:56:44

标签: npm sass

package.json

"scripts": {
    "start": "nodemon index.js",
    "watch-sass": "sass --watch scss/styles.scss css/styles.css",
    "test": "echo \"Error: no test specified\" && exit 1"
  },

执行npm-start而不执行npm watch-sass时没有问题。我不知道出了什么问题,但是命令无法识别,我直接在控制台上输入sass --watch scss/styles.scss css/styles.css,它可以正常工作。

1 个答案:

答案 0 :(得分:1)

使用

npm run watch-sass

npm start起作用的原因是 npm testnpm startnpm restartnpm stop都是npm run xxx的别名。由于watch-sass不属于默认值,因此需要在语句中使用明确的run

有关更多详细信息,请访问:https://docs.npmjs.com/cli/run-script