node.js - Firebase dağıtımı tsc komutunda hata veriyor
Bazı temel Firebase Fonksiyonları oluşturmak için bir Firebase projesi kurdum.
Projede TypeScript kullanıyorum
Firebase resmi dokümantasyonunu takip ederek projemi oluşturdum.
Son adım olan firebase deploy --only functions, tsc komutuyla bir hata verdi.
firebase deploy --only functions
=== Deploying to ‘my-project’…
i deploying functions
Running command: npm --prefix "$RESOURCE_DIR" run lint
> functions@ lint /path/to/functions
> tslint --project tsconfig.json
Running command: npm --prefix "$RESOURCE_DIR" run build
> functions@ build /path/to/functions
> tsc
node_modules/firebase-functions/lib/function-builder.d.ts(60,95): error TS1005: ';' expected.
node_modules/firebase-functions/lib/function-builder.d.ts(60,96): error TS1003: Identifier expected.
node_modules/firebase-functions/lib/function-builder.d.ts(60,116): error TS1005: ';' expected.
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! /some/path/.npm/_logs/2019-02-03T00_10_30_573Z-debug.log
Error: functions predeploy error: Command terminated with non-zero exit code2
Having trouble? Try firebase deploy --help
Görünüşe göre bazı Firebase kütüphanesi kodları tsc derleme/transpile adımını geçemiyor. Bu dağıtım adımının geçmesini sağlayacak bir yol arıyorum.
Bu GitHub sorununda verilen öneriyi takip ettim, ki bu şunları içeriyordu:
tsckomutuna--skipLibCheckeklemek- Projeye oluşturulan
functions/tsconfig.jsondosyasınaskipLibCheckeklemek functions/tsconfig.jsondosyasınaisolateModuleseklemekfunctions/tsconfig.jsondosyasındakitypeRootsdizisine./functions/node_modules/@typesekleniyor.functions/tsconfig.jsondosyasındakicompilerOptions.lib'adomeklemek
Yukarıdaki adımların hiçbiri benim için işe yaramadı.
Firebase'e dağıtımımı nasıl başarılı kılabilirim?
Cevap #1
Aynı sorunla karşılaştım, typescript kütüphanesini 3.3.1 sürümüne yükselttikten ve npm install yaptıktan sonra dağıtımı yapabildim.
package.json dosyasında şunu ayarlayın: "devDependencies": { "tslint": "~5.8.0", "typescript": "~3.3.1" },
Not: Gönderinizde açıklanan tüm değişiklikleri kaldırabilirsiniz.
Cevap #2
bu benim için işe yarıyor: functions klasörü içindeki tsconfig'e bu satırı ekle:
"typeRoots": [ "node_modules/@types" ],
Bu, benim için çalışan "compilerOptions" bloğunun bir parçasıdır