我正在尝试创建我的第一个Firestore Cloud功能,并完成Get Started方向。但是当我尝试部署我的Hello World脚本时,我收到以下错误:
=== Deploying to 'myproject-dev'...
i deploying functions
Running command: npm --prefix "$RESOURCE_DIR" run lint
> functions@ lint /Users/nlam/Dropbox/dev/myproject/backend/functions
> tslint --project tsconfig.json
module.js:549
throw err;
^
Error: Cannot find module '../lib/tslint-cli'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/nlam/Dropbox/dev/myproject/backend/functions/node_modules/.bin/tslint:3:1)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! functions@ lint: `tslint --project tsconfig.json`
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! /Users/nlam/.npm/_logs/2018-05-23T15_43_46_608Z-debug.log
Error: functions predeploy error: Command terminated with non-zero exit code1
我的功能非常简单:
import * as functions from 'firebase-functions';
export const helloworld = functions.https.onRequest((request, response) => {
response.send("hello, world");
});
这是上面引用的日志的内容:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli '--prefix',
1 verbose cli '/Users/nlam/Dropbox/dev/myproject/backend/functions',
1 verbose cli 'run',
1 verbose cli 'lint' ]
2 info using npm@6.0.1
3 info using node@v8.11.1
4 verbose run-script [ 'prelint', 'lint', 'postlint' ]
5 info lifecycle functions@~prelint: functions@
6 info lifecycle functions@~lint: functions@
7 verbose lifecycle functions@~lint: unsafe-perm in lifecycle true
8 verbose lifecycle functions@~lint: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/nlam/Dropbox/dev/myproject/backend/functions/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
9 verbose lifecycle functions@~lint: CWD: /Users/nlam/Dropbox/dev/myproject/backend/functions
10 silly lifecycle functions@~lint: Args: [ '-c', 'tslint --project tsconfig.json' ]
11 silly lifecycle functions@~lint: Returned: code: 1 signal: null
12 info lifecycle functions@~lint: Failed to exec lint script
13 verbose stack Error: functions@ lint: `tslint --project tsconfig.json`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:283:16)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at EventEmitter.emit (events.js:214:7)
13 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at ChildProcess.emit (events.js:214:7)
13 verbose stack at maybeClose (internal/child_process.js:925:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid functions@
15 verbose cwd /Users/nlam/Dropbox/dev/myproject/backend
16 verbose Darwin 17.5.0
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "--prefix" "/Users/nlam/Dropbox/dev/myproject/backend/functions" "run" "lint"
18 verbose node v8.11.1
19 verbose npm v6.0.1
20 error code ELIFECYCLE
21 error errno 1
22 error functions@ lint: `tslint --project tsconfig.json`
22 error Exit status 1
23 error Failed at the functions@ lint script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
我尝试使用:
安装tslintsudo npm install -g tslint
但我仍然遇到同样的错误。
任何帮助将不胜感激。提前谢谢。
答案 0 :(得分:2)
您可以尝试在终端上输入以下代码吗?
tslint --project tsconfig.json
如果显示
no-unused-variable is deprecated. Since TypeScript 2.9. Please use the built-in compiler checks instead.
然后从函数文件夹中的"no-unused-variable": {"severity": "warning"},
文件中删除tslint.json
如果显示其他内容,您可以在此处发布错误,以便我们看看吗?
答案 1 :(得分:2)
删除您的node_modules
目录并重新安装节点软件包。
rm -rf node_modules
npm install