无法将“ eslint”识别为内部或外部命令,可操作程序或批处理文件

时间:2019-02-21 14:42:49

标签: firebase google-cloud-functions eslint npm-scripts

'eslint' is not recognized as an internal or external command,
operable program or batch file.
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\SURAJ SURESH\AppData\Roaming\npm-cache\_logs\2019-02-21T14_17_08_699Z-debug.log
events.js:174
      throw er; // Unhandled 'error' event
      ^

Error: spawn npm --prefix "C:\Users\SURAJ SURESH\Desktop\firecast\functions" run lint ENOENT
    at notFoundError (C:\Users\SURAJ SURESH\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:6:26)
    at verifyENOENT (C:\Users\SURAJ SURESH\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:40:16)
    at ChildProcess.cp.emit (C:\Users\SURAJ SURESH\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:27:25)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
Emitted 'error' event at:
    at ChildProcess.cp.emit (C:\Users\SURAJ SURESH\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:30:37)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)

Error: functions predeploy error: Command terminated with non-zero exit code1

这是我第一次使用firbase函数。我尝试部署功能,并且发生了这种情况。我尝试从

编辑firebase.json文件
{
  "functions": {
    "predeploy": [
      "npm --prefix \"RESOURCE_DIR\" run lint"
    ]
  }
}

{
  "functions": {
    "predeploy": [
      "npm --prefix \"%RESOURCE_DIR%\" run lint"
    ]
  }
}

但是没有任何效果。我只是按照firecast教程开始使用Firebase云功能。

1 个答案:

答案 0 :(得分:0)

我认为这是因为您的firebase.json内正在尝试使用eslint模块,而您没有安装此模块。

即:"npm --prefix \"%RESOURCE_DIR%\" run lint"

也许您可以尝试为eslint安装必要的eslint库和关联的CLI:

npm i --save-dev eslint
npm install -g eslint-cli

注意:cli必须全局安装,而eslint模块应该本地安装。 Docs

希望有帮助!