首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在npm脚本中使用sass-lint会导致错误。

在npm脚本中使用sass-lint会导致错误。
EN

Stack Overflow用户
提问于 2017-03-14 11:57:04
回答 1查看 1.6K关注 0票数 2

我正在用角键制作一个应用程序。我将用SCSS编写我的样式,因此我希望我的SCSS文件可以使用linting。当使用角-cli创建应用程序时,节点-sass已经安装,并且我已经在本地安装了厚皮棉

现在我可以从命令行成功地运行linting命令:

代码语言:javascript
复制
./node_modules/.bin/sass-lint 'src/**/*.scss' -v -q

这给了我一系列的错误和警告:

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

但是,当我将这个comand作为package.json中的NPM脚本添加时,它会产生一个错误,尽管它也给出了linting的结果:

代码语言:javascript
复制
{
    ...
    "scripts": {
        "scsslint": "./node_modules/.bin/sass-lint 'src/**/*.scss' -v -q"
    }
    ...
}

成果产出:

代码语言:javascript
复制
> 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产生的日志输出:

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

我想不出是什么导致了这个错误。谁能给我指明正确的方向?

EN

回答 1

Stack Overflow用户

发布于 2017-09-13 13:55:48

该错误很可能是由代码中捕获的Sass linter错误触发的。

每次发生这种情况时,sass-lint都会将退出代码设置为1(错误),这反过来又会被Node.js环境所获取--因此,所有这些ERR日志条目都会被捕获。

如果您只使用linter warnings,退出代码将为0(或“成功”),并且该问题不会出现。

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

https://stackoverflow.com/questions/42785373

复制
相关文章

相似问题

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