首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >NPM - npm手表不工作

NPM - npm手表不工作
EN

Stack Overflow用户
提问于 2016-06-09 17:52:29
回答 2查看 4.1K关注 0票数 1

我正在创建一个简单的npm监视来监视和生成sass文件。

我有这个代码

代码语言:javascript
复制
    {
      "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"
      }
    }

我得到了这个错误

代码语言:javascript
复制
    > 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‘,它可以工作,但不能运行手表

EN

回答 2

Stack Overflow用户

发布于 2016-06-09 20:55:07

假设您使用的是watch,它只在命令行中接受一个目录参数,而不是一个文件通配符。我刚在我自己的系统上确认了这一点。

你可以通过编程的方式使用watch来做更有趣或更复杂的things...but。

您可以将行更改为watch 'npm run scss' css/,也可以查看更具编程性的内容,如监视脚本或更复杂的内容,如基于哼唱或吞咽的方法。

票数 2
EN

Stack Overflow用户

发布于 2019-09-19 16:36:38

Windows OS下也要注意。在使用Windows时,我遇到了使用简单引号的问题。以下内容对我不起作用:

代码语言:javascript
复制
"watch:css": "watch 'npm run scss' ./scss --interval=1"

而下一个是正确的:

代码语言:javascript
复制
"watch:css": "watch \"npm run scss\" ./scss --interval=1"

注意转义的引号

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37722550

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档