我正在创建一个简单的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‘,它可以工作,但不能运行手表
发布于 2016-06-09 20:55:07
假设您使用的是watch,它只在命令行中接受一个目录参数,而不是一个文件通配符。我刚在我自己的系统上确认了这一点。
你可以通过编程的方式使用watch来做更有趣或更复杂的things...but。
您可以将行更改为watch 'npm run scss' css/,也可以查看更具编程性的内容,如监视脚本或更复杂的内容,如基于哼唱或吞咽的方法。
发布于 2019-09-19 16:36:38
在Windows OS下也要注意。在使用Windows时,我遇到了使用简单引号的问题。以下内容对我不起作用:
"watch:css": "watch 'npm run scss' ./scss --interval=1"而下一个是正确的:
"watch:css": "watch \"npm run scss\" ./scss --interval=1"注意转义的引号。
https://stackoverflow.com/questions/37722550
复制相似问题