【问题标题】:firebase deploy error: 'eslint is not recognized as an internal or external command, operable program or batch file'firebase 部署错误:“eslint 未被识别为内部或外部命令、可运行程序或批处理文件”
【发布时间】:2020-11-29 03:18:49
【问题描述】:

我想使用 firebase 托管。所以我按照文档中的说明安装firebase cli ...我尝试部署并收到此错误

    ←[33m>←[39m firebase deploy

    === Deploying to 'firebase-project-id'...

    i  deploying database, storage, firestore, functions, hosting
    Running command: npm --prefix "$RESOURCE_DIR" run lint

    > functions@ lint C:\Users\somto\Desktop\xampp3\htdocs\firebaseProjectFolder\functions
    > eslint .

    '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\somto\AppData\Roaming\npm-cache\_logs\2020-08-09T08_37_19_
    192Z-debug.log
    events.js:292
    throw er; // Unhandled 'error' event
  ^

   Error: spawn npm --prefix "%RESOURCE_DIR%" run lint ENOENT
   at notFoundError (C:\Users\somto\.cache\firebase\tools\lib\node_modules\cros
   s-env\node_modules\cross-spawn\lib\enoent.js:6:26)
   at verifyENOENT (C:\Users\somto\.cache\firebase\tools\lib\node_modules\cross
   -env\node_modules\cross-spawn\lib\enoent.js:40:16)
   at ChildProcess.cp.emit (C:\Users\somto\.cache\firebase\tools\lib\node_modul
   es\cross-env\node_modules\cross-spawn\lib\enoent.js:27:25)
   at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
   Emitted 'error' event on ChildProcess instance at:
   at ChildProcess.cp.emit (C:\Users\somto\.cache\firebase\tools\lib\node_modul
   es\cross-env\node_modules\cross-spawn\lib\enoent.js:30:37)
   at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12) {
   code: 'ENOENT',
   errno: 'ENOENT',
   syscall: 'spawn npm --prefix "%RESOURCE_DIR%" run lint',
   path: 'npm --prefix "%RESOURCE_DIR%" run lint',
   spawnargs: []
   }

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

我尝试过像这样在全局范围内安装 eslint

   npm install -g install eslint

本地也这样

   npm install eslint -save-dev

我收到了这个错误

   ←[33m>←[39m npm install eslint -save-dev
   npm WARN tar EPERM: operation not permitted, open 'C:\Users\somto\Desktop\xampp3
   \htdocs\firebaseFocalSells\functions\node_modules\.staging\emoji-regex-4cb87742\
   LICENSE-MIT.txt'
   npm WARN tar EPERM: operation not permitted, open 'C:\Users\somto\Desktop\xampp3
   \htdocs\firebaseFocalSells\functions\node_modules\.staging\mkdirp-b8ac9146\bin\u
   sage.txt'
   npm WARN tar EPERM: operation not permitted, open 'C:\Users\somto\Desktop\xampp3
   \htdocs\firebaseFocalSells\functions\node_modules\.staging\path-is-inside-4de37f
   7b\LICENSE.txt'
   npm WARN tar EPERM: operation not permitted, open 'C:\Users\somto\Desktop\xampp3
   \htdocs\firebaseFocalSells\functions\node_modules\.staging\tslib-b2cb758c\Copyri
   ghtNotice.txt'
   npm WARN tar EPERM: operation not permitted, open 'C:\Users\somto\Desktop\xampp3
   \htdocs\firebaseFocalSells\functions\node_modules\.staging\mute-stream-a7e5c2a3\
   coverage\lcov-report\sort-arrow-sprite.png'
   npm WARN tar EPERM: operation not permitted, open 'C:\Users\somto\Desktop\xampp3
   \htdocs\firebaseFocalSells\functions\node_modules\.staging\tslib-b2cb758c\LICENS
   E.txt'
   npm WARN tar EPERM: operation not permitted, open 'C:\Users\somto\Desktop\xampp3
   \htdocs\firebaseFocalSells\functions\node_modules\.staging\signal-exit-b8765d91\
   LICENSE.txt'
   npm WARN tar EPERM: operation not permitted, open 'C:\Users\somto\Desktop\xampp3
   \htdocs\firebaseFocalSells\functions\node_modules\.staging\punycode-13837a7e\LIC
   ENSE-MIT.txt'
   npm WARN tar EPERM: operation not permitted, open 'C:\Users\somto\Desktop\xampp3
   \htdocs\firebaseFocalSells\functions\node_modules\.staging\esquery-038cd083\lice
   nse.txt'
   npm WARN tar EPERM: operation not permitted, open 'C:\Users\somto\Desktop\xampp3
   \htdocs\firebaseFocalSells\functions\node_modules\.staging\eslint-49825a49\messa
   ges\all-files-ignored.txt'
  npm WARN tar EPERM: operation not permitted, open 'C:\Users\somto\Desktop\xampp3
  \htdocs\firebaseFocalSells\functions\node_modules\.staging\eslint-49825a49\messa
  ges\extend-config-missing.txt'
  npm WARN tar EPERM: operation not permitted, open 'C:\Users\somto\Desktop\xampp3
  \htdocs\firebaseFocalSells\functions\node_modules\.staging\eslint-49825a49\messa
  ges\failed-to-read-json.txt'
  npm WARN tar EPERM: operation not permitted, open 'C:\Users\somto\Desktop\xampp3
  \htdocs\firebaseFocalSells\functions\node_modules\.staging\eslint-49825a49\messa
  ges\file-not-found.txt'
  npm WARN tar EPERM: operation not permitted, open 'C:\Users\somto\Desktop\xampp3
  \htdocs\firebaseFocalSells\functions\node_modules\.staging\eslint-49825a49\messa
  ges\no-config-found.txt'
  npm WARN tar EPERM: operation not permitted, open 'C:\Users\somto\Desktop\xampp3
  \htdocs\firebaseFocalSells\functions\node_modules\.staging\eslint-49825a49\messa
  ges\plugin-missing.txt'
  npm WARN tar EPERM: operation not permitted, open 'C:\Users\somto\Desktop\xampp3
  \htdocs\firebaseFocalSells\functions\node_modules\.staging\eslint-49825a49\messa
  ges\whitespace-found.txt'
  npm WARN tar EPERM: operation not permitted, open 'C:\Users\somto\Desktop\xampp3
  \htdocs\firebaseFocalSells\functions\node_modules\.staging\rxjs-d9c29a17\_esm201
  5\LICENSE.txt'
 npm ERR! cb() never called!

 npm ERR! This is an error with npm itself. Please report this error at:
 npm ERR!     <https://npm.community>

 npm ERR! A complete log of this run can be found in:
 npm ERR!     C:\Users\somto\AppData\Roaming\npm-cache\_logs\2020-08-09T08_06_37_
 190Z-debug.log

我也试过了

   npm -g i eslint-cli

得到了已经存在的错误

请问,我该如何解决这个问题? 我正在使用 Windows 7

【问题讨论】:

  • 解决了吗?

标签: npm eslint windows-7-x64 firebase-hosting firebase-cli


【解决方案1】:

你有一个小错字。而不是:

npm install eslint -save-dev

使用

npm install eslint --save-dev

这可能是问题:)

【讨论】:

    【解决方案2】:

    如果您正在使用 firebase 函数或使用项目文件夹,请将目录更改为您的函数文件夹,并使用 npm i 安装依赖项。 package.json 看起来像这样:

    "devDependencies":
    {
        "eslint": "^7.6.0",
        "eslint-config-google": "^0.14.0",
        "firebase-functions-test": "^0.2.0"
    }
    

    现在使用npm run build 构建并使用firebase deploy 进行部署。

    【讨论】:

      【解决方案3】:

      尝试使用重新初始化firebase

      firebase init
      

      【讨论】:

        猜你喜欢
        • 2021-09-07
        • 2015-12-30
        • 2018-07-08
        • 2023-03-22
        • 1970-01-01
        • 1970-01-01
        • 2022-01-22
        相关资源
        最近更新 更多