我正在使用 angular-cli 组合一个应用程序。我将在 SCSS 中编写我的样式,因此我希望为我的 SCSS 文件提供 linting。使用 angular-cli 创建应用程序时已经安装了 Node-sass,并且我已经在本地安装了sass-lint 。
我现在可以从命令行成功运行 linting 命令:
./node_modules/.bin/sass-lint 'src/**/*.scss' -v -q
这给了我一个错误和警告列表:
src/app/app.component.scss
2:3 error Expected `background-color`, found `color` property-sort-order
2:10 warning Color 'red' should be written in its hexadecimal form #ff0000 no-color-keywords
2:10 warning Color literals such as 'red' should only be used in variable declarations no-color-literals
3:3 error Expected `color`, found `background-color` property-sort-order
3:21 warning Color 'blue' should be written in its hexadecimal form #0000ff no-color-keywords
3:21 warning Color literals such as 'blue' should only be used in variable declarations no-color-literals
但是,当我将此命令作为 NPM 脚本添加时,package.json
它会产生错误,即使它也给了我 linting 的结果:
{
...
"scripts": {
"scsslint": "./node_modules/.bin/sass-lint 'src/**/*.scss' -v -q"
}
...
}
结果输出:
> starter@0.0.0 scsslint /home/brian/Projects/tutorials/angular2/starter
> sass-lint 'src/**/*.scss' -v -q
src/app/app.component.scss
2:3 error Expected `background-color`, found `color` property-sort-order
2:10 warning Color 'red' should be written in its hexadecimal form #ff0000 no-color-keywords
2:10 warning Color literals such as 'red' should only be used in variable declarations no-color-literals
3:3 error Expected `color`, found `background-color` property-sort-order
3:21 warning Color 'blue' should be written in its hexadecimal form #0000ff no-color-keywords
3:21 warning Color literals such as 'blue' should only be used in variable declarations no-color-literals
✖ 6 problems (2 errors, 4 warnings)
npm ERR! Linux 4.4.0-64-generic
npm ERR! argv "/usr/local/bin/node" "/home/brian/.npm-packages/bin/npm" "run" "scsslint"
npm ERR! node v6.9.4
npm ERR! npm v4.3.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! starter@0.0.0 scsslint: `sass-lint 'src/**/*.scss' -v -q`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the starter@0.0.0 scsslint script 'sass-lint 'src/**/*.scss' -v -q'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the starter package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! sass-lint 'src/**/*.scss' -v -q
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs starter
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls starter
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/brian/.npm/_logs/2017-03-14T11_52_04_406Z-debug.log
这是 NPM 的结果日志输出:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
1 verbose cli '/home/brian/.npm-packages/bin/npm',
1 verbose cli 'run',
1 verbose cli 'scsslint' ]
2 info using npm@4.3.0
3 info using node@v6.9.4
4 verbose run-script [ 'prescsslint', 'scsslint', 'postscsslint' ]
5 info lifecycle starter@0.0.0~prescsslint: starter@0.0.0
6 silly lifecycle starter@0.0.0~prescsslint: no script for prescsslint, continuing
7 info lifecycle starter@0.0.0~scsslint: starter@0.0.0
8 verbose lifecycle starter@0.0.0~scsslint: unsafe-perm in lifecycle true
9 verbose lifecycle starter@0.0.0~scsslint: PATH: /home/brian/.npm-packages/lib/node_modules/npm/bin/node-gyp-bin:/home/brian/Projects/tutorials/angular2/starter/node_modules/.bin:/home/brian/.npm-packages/bin:/home/brian/bin:/home/brian/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin
10 verbose lifecycle starter@0.0.0~scsslint: CWD: /home/brian/Projects/tutorials/angular2/starter
11 silly lifecycle starter@0.0.0~scsslint: Args: [ '-c', 'sass-lint \'src/**/*.scss\' -v -q' ]
12 silly lifecycle starter@0.0.0~scsslint: Returned: code: 1 signal: null
13 info lifecycle starter@0.0.0~scsslint: Failed to exec scsslint script
14 verbose stack Error: starter@0.0.0 scsslint: `sass-lint 'src/**/*.scss' -v -q`
14 verbose stack Exit status 1
14 verbose stack at EventEmitter.<anonymous> (/home/brian/.npm-packages/lib/node_modules/npm/lib/utils/lifecycle.js:279:16)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at EventEmitter.emit (events.js:191:7)
14 verbose stack at ChildProcess.<anonymous> (/home/brian/.npm-packages/lib/node_modules/npm/lib/utils/spawn.js:40:14)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at ChildProcess.emit (events.js:191:7)
14 verbose stack at maybeClose (internal/child_process.js:877:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
15 verbose pkgid starter@0.0.0
16 verbose cwd /home/brian/Projects/tutorials/angular2/starter
17 error Linux 4.4.0-64-generic
18 error argv "/usr/local/bin/node" "/home/brian/.npm-packages/bin/npm" "run" "scsslint"
19 error node v6.9.4
20 error npm v4.3.0
21 error code ELIFECYCLE
22 error errno 1
23 error starter@0.0.0 scsslint: `sass-lint 'src/**/*.scss' -v -q`
23 error Exit status 1
24 error Failed at the starter@0.0.0 scsslint script 'sass-lint 'src/**/*.scss' -v -q'.
24 error Make sure you have the latest version of node.js and npm installed.
24 error If you do, this is most likely a problem with the starter package,
24 error not with npm itself.
24 error Tell the author that this fails on your system:
24 error sass-lint 'src/**/*.scss' -v -q
24 error You can get information on how to open an issue for this project with:
24 error npm bugs starter
24 error Or if that isn't available, you can get their info via:
24 error npm owner ls starter
24 error There is likely additional logging output above.
25 verbose exit [ 1, true ]
我无法弄清楚如何找到导致此错误的原因。谁能指出我正确的方向?