首页 > 解决方案 > onchange 的问题,它无法识别 scss 文件的更改

问题描述

我将 onchange 插件安装到我的项目中,但是当我在 npm 上执行“watch:scss”时,我无法让脚本运行,它只是没有检测到我的文件有任何更改,可能是语法错误,但我检查了很多的时候,希望有人可以帮助:)

    {
  "name": "guia-hoteles",
  "version": "1.0.0",
  "description": "Primer proyecto de Node.js",
  "main": "index.html",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "dev": "lite-server",
    "scss": "node-sass -o css/ css/",
    "watch:scss": "onchange 'css/*.scss' -- npm run scss ",
    "start": "concurrently \"npm run watch:scss\" \"npm run dev\""
  },
  "repository": {
    "type": "git",
    "url": "git+https://juani_olguin@bitbucket.org/juani_olguin/guia-hoteles.git"
  },
  "author": "Juan Ignacio Olguin",
  "license": "ISC",
  "homepage": "https://bitbucket.org/juani_olguin/guia-hoteles#readme",
  "devDependencies": {
    "lite-server": "^2.5.4",
    "node-sass": "^4.14.1",
    "onchange": "^7.0.2",
    "rimraf": "^3.0.2"
  },
  "dependencies": {
    "@popperjs/core": "^2.5.3",
    "bootstrap": "^4.5.2",
    "concurrently": "^5.3.0",
    "jquery": "^3.5.1",
    "open-iconic": "^1.1.1",
    "popper.js": "^1.16.1"
  }
}

这就是我运行脚本时 git 的样子

标签: npmscripting

解决方案


如果你使用的是Windows,基本上你只需要用双引号改变单引号并将双引号转义,如下所示:

"watch:scss": "onchange \\"css/*.scss\\" -- npm run scss ",

推荐阅读