Seb*_*ien 5 npm firebase typescript google-cloud-functions
我尝试更新Firebase函数项目的依赖项,以使用最新版本的firebase-functions和firebase-admin,这反过来又似乎需要更新版本的TypeScript和tslint。这是我生成的package.json:
{
"name": "functions",
"scripts": {
"lint": "./node_modules/.bin/tslint -p tslint.json",
"build": "./node_modules/.bin/tsc",
"serve": "npm run build && firebase serve --only functions",
"shell": "npm run build && firebase experimental:functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"main": "lib/index.js",
"engines": {
"node": "8"
},
"dependencies": {
"@types/jsonwebtoken": "^7.2.8",
"axios": "^0.18.1",
"body-parser": "^1.18.3",
"express": "^4.16.3",
"firebase-admin": "^8.0.0",
"firebase-functions": "^3.1.0",
"handlebars": "^4.1.2",
"html-pdf": "^2.2.0",
"js-sha256": "^0.9.0",
"json2csv": "^4.1.2",
"jsonwebtoken": "^8.3.0",
"jwks-rsa": "^1.3.0",
"moment": "^2.24.0",
"pdfkit": "^0.9.1",
"uuid": "^3.3.2",
"validator": "^10.11.0"
},
"devDependencies": {
"tslint": "^5.12.0",
"typescript": "^3.2.2"
},
"private": true
}
Run Code Online (Sandbox Code Playgroud)
但是现在,当我尝试部署Firebase函数时,出现了很多TypeScript编译错误,我什至无法理解。任何人都知道它们是什么以及如何修复或解决它们吗?
Running command: npm --prefix $RESOURCE_DIR run build
> functions@ build /Users/sarbogast/dev/myproject/backend/functions
> tsc
node_modules/@google-cloud/storage/build/src/file.d.ts:35:29 - error TS2694: Namespace '"http"' has no exported member 'OutgoingHttpHeaders'.
35 extensionHeaders?: http.OutgoingHttpHeaders;
~~~~~~~~~~~~~~~~~~~
node_modules/@types/node/index.d.ts:54:11 - error TS2300: Duplicate identifier 'IteratorResult'.
54 interface IteratorResult<T> {}
~~~~~~~~~~~~~~
node_modules/typescript/lib/lib.es2015.iterable.d.ts:41:6
41 type IteratorResult<T, TReturn = any> = IteratorYieldResult<T> | IteratorReturnResult<TReturn>;
~~~~~~~~~~~~~~
'IteratorResult' was also declared here.
node_modules/typescript/lib/lib.es2015.iterable.d.ts:41:6 - error TS2300: Duplicate identifier 'IteratorResult'.
41 type IteratorResult<T, TReturn = any> = IteratorYieldResult<T> | IteratorReturnResult<TReturn>;
~~~~~~~~~~~~~~
node_modules/@types/node/index.d.ts:54:11
54 interface IteratorResult<T> {}
~~~~~~~~~~~~~~
'IteratorResult' was also declared here.
Found 3 errors.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! functions@ build: `tsc`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the functions@ build 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/sarbogast/.npm/_logs/2019-09-03T14_57_53_748Z-debug.log
Error: functions predeploy error: Command terminated with non-zero exit code2
Run Code Online (Sandbox Code Playgroud)
所以这就是我如何解决这个问题的:我安装了 @types/node 作为显式的开发依赖项,这就足够了。这是我的 package.json 最终的样子:
{
"name": "functions",
"scripts": {
"lint": "./node_modules/.bin/tslint -p tslint.json",
"build": "./node_modules/.bin/tsc",
"serve": "npm run build && firebase serve --only functions",
"shell": "npm run build && firebase experimental:functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"engines": {
"node": "8"
},
"main": "lib/index.js",
"dependencies": {
"@types/jsonwebtoken": "^7.2.8",
"axios": "^0.18.1",
"body-parser": "^1.18.3",
"express": "^4.16.3",
"firebase-admin": "^8.5.0",
"firebase-functions": "^3.2.0",
"handlebars": "^4.1.2",
"html-pdf": "^2.2.0",
"js-sha256": "^0.9.0",
"json2csv": "^4.1.2",
"jsonwebtoken": "^8.3.0",
"jwks-rsa": "^1.3.0",
"moment": "^2.24.0",
"pdfkit": "^0.9.1",
"uuid": "^3.3.2",
"validator": "^10.11.0"
},
"devDependencies": {
"@types/node": "^12.7.5",
"tslint": "~5.8.0",
"typescript": "^3.6.3"
},
"private": true
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
310 次 |
| 最近记录: |