NPM-NPM手表不工作

NPM-NPM手表不工作,npm,Npm,我正在创建一个简单的npm手表来观看并生成一个sass文件 我有这个密码 { "name": "npm-test", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "scss": "node-sass --output-style compressed -o css/output css/*scss",

我正在创建一个简单的npm手表来观看并生成一个sass文件

我有这个密码

    {
      "name": "npm-test",
      "version": "1.0.0",
      "description": "",
      "main": "index.js",
      "scripts": {
         "scss": "node-sass --output-style compressed -o css/output css/*scss",
         "watch": "watch 'npm run scss' css/*.scss"

      },
      "author": "",
      "license": "ISC",
      "devDependencies": {
        "node-sass": "^3.7.0",
        "watch": "^0.18.0"
      }
    }
我犯了这个错误

    > npm-test@1.0.0 watch /Users/ch-d/Desktop/npm-test
    > watch 'npm run scss' css/*.scss

    > Watching css/main.scss
    /Users/ch-d/Desktop/npm-test/node_modules/watch/main.js:73
        if (err) throw err;
                       ^
    Error: ENOTDIR, scandir 'css/main.scss'
        at Error (native)

    npm ERR! Darwin 15.4.0
    npm ERR! argv "node" "/usr/local/bin/npm" "run" "watch"
    npm ERR! node v0.12.4
    npm ERR! npm  v2.10.1
    npm ERR! code ELIFECYCLE
    npm ERR! npm-test@1.0.0 watch: `watch 'npm run scss' css/*.scss`
    npm ERR! Exit status 1
    npm ERR!
    npm ERR! Failed at the npm-test@1.0.0 watch script 'watch 'npm run scss' css/*.scss'.
    npm ERR! This is most likely a problem with the npm-test package,
    npm ERR! not with npm itself.
    npm ERR! Tell the author that this fails on your system:
    npm ERR!     watch 'npm run scss' css/*.scss
    npm ERR! You can get their info via:
    npm ERR!     npm owner ls npm-test
    npm ERR! There is likely additional logging output above.

    npm ERR! Please include the following file with any support request:
    npm ERR!     /Users/ch-d/Desktop/npm-test/npm-debug.log     
我可以运行'npm run scss',这可以运行,但手表不能运行假定您正在使用,它只在命令行接受一个目录参数,而不是一个文件通配符。我刚刚在自己的系统上确认了这一点

您可以通过编程方式使用watch来完成更有趣或更复杂的事情……但是CLI非常基本


您可以将该行更改为
watch'npm run scss'css/
,或者您可以查看更具编程性的内容,如watch脚本或更复杂的内容,如基于咕噜声或咕噜声的方法。

Windows操作系统下也要注意。使用Windows时,我遇到了使用简单引号的问题。以下内容不适用于我:

"watch:css": "watch 'npm run scss' ./scss --interval=1"
而下一个是正确的:

"watch:css": "watch \"npm run scss\" ./scss --interval=1"
注意转义的引号