问题描述
每次我在 Visaul studio 中输入命令“firebase deploy --only functions”。 VisualSTD 向我显示此错误消息
"命令 "eslint." 要么拼写错误,要么 找不到。”
我想将 firebase 连接到我的应用程序,但每次都会出现此错误。我不知道有什么问题已经包含了所有其他功能
{
"name": "functions","description": "Cloud Functions for Firebase","scripts": {
"lint": "eslint.","serve": "firebase emulators:start --only functions","shell": "firebase functions:shell","start": "npm run shell","deploy": "firebase deploy --only functions","logs": "firebase functions:log"
},"engines": {
"node": "12"
},"main": "index.js","dependencies": {
"nodemailer": "6.4.17","firebase-admin": "^9.2.0","firebase-functions": "^3.11.0"
},"devDependencies": {
"eslint": "^7.6.0","eslint-config-google": "^0.14.0","firebase-functions-test": "^0.2.0"
},"private": true
}
这就是我在控制台中得到的
The command "eslint." is either misspelled or
Could not be found.
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\samo1\AppData\Roaming\npm-cache\_logs\2021-01-28T15_12_42_887Z-debug.log
events.js:292
throw er; // Unhandled 'error' event
^
Error: spawn npm --prefix "%rESOURCE_DIR%" run lint ENOENT
at notFoundError (C:\Users\samo1\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:6:26)
at verifyENOENT (C:\Users\samo1\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\samo1\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:277:12)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12) {
code: 'ENOENT',errno: 'ENOENT',syscall: 'spawn npm --prefix "%rESOURCE_DIR%" run lint',path: 'npm --prefix "%rESOURCE_DIR%" run lint',spawnargs: []
}
解决方法
先尝试全局安装 eslint-cli
npm -g i eslint-cli
然后在您的项目文件夹中
npm i eslint --save-dev