Firebase 部署错误:'eslint 不被识别为内部或外部命令,可执行程序或批处理文件'。

6

我想使用 Firebase Hosting。因此,我按照文档中的说明安装了 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 操作系统。


这个问题解决了吗? - Isuru Herath
3个回答

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 部署。

2

你有一个小错误。应该是:

npm install eslint -save-dev

使用

npm install eslint --save-dev

这可能是问题的原因 :)

0

尝试使用以下方法重新初始化 Firebase

firebase init

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接