首页 > 解决方案 > 我从 nodejs index.js 得到的 Javascript 不常见错误

问题描述

我不明白如何从运行 javascript index.js 文件中得到这个错误,我的项目是一个 firebase 函数,这是来自 nodejs index.js 脚本的错误,我使用 Visual Studio 作为 IDE。

   3:1   error  Expected space or tab after '//' in comment           spaced-comment
   4:1   error  Expected space or tab after '//' in comment           spaced-comment
  13:1   error  This line has a length of 126. Maximum allowed is 80  max-len
  13:89  error  Missing semicolon                                     semi
  17:16  error  Strings must use doublequote                          quotes
  17:68  error  Missing trailing comma                                comma-dangle
  21:1   error  Missing JSDoc comment                                 require-jsdoc
  21:18  error  Missing space before opening brace                    space-before-blocks
  22:1   error  Expected indentation of 2 spaces but found 4          indent
  26:1   error  Expected indentation of 2 spaces but found 4          indent
  26:5   error  Unexpected var, use let or const instead              no-var
  26:17  error  Multiple spaces found before 'req'                    no-multi-spaces
  27:1   error  Expected indentation of 2 spaces but found 4          indent
  27:5   error  Unexpected var, use let or const instead              no-var
  28:1   error  Expected indentation of 2 spaces but found 4          indent
  28:5   error  Expected space(s) after "if"                          keyword-spacing
  28:14  error  Missing space before opening brace                    space-before-blocks
  29:1   error  Expected indentation of 4 spaces but found 8          indent
  29:28  error  Trailing spaces not allowed                           no-trailing-spaces
  30:1   error  Expected indentation of 2 spaces but found 4          indent
  31:4   error  Newline required at end of file but not found         eol-last

✖ 21 problems (21 errors, 0 warnings)
  19 errors and 0 warnings potentially fixable with the `--fix` option.


npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! functions@ lint: `eslint .`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the functions@ lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\chris\AppData\Roaming\npm-cache\_logs\2021-06-07T04_32_11_868Z-debug.log
events.js:288
      throw er; // Unhandled 'error' event

标签: javascriptnode.jsgoogle-cloud-functionseslint

解决方案


在项目的functions文件夹内"lint": "eslint .""lint": "eslint" 文件中更改 package.json


推荐阅读