6.2.2
OSX
$ firebase init
Pilih konfigurasi untuk kedua fungsi dan hosting. Kemudian TypeScript dan ya untuk TSLint.
Salin tempel di bawah ini ke functions/src/index.ts:
import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin';
admin.initializeApp();
// Most basic HTTP Funtion
export const basicHTTP = functions.https.onRequest((request, response) => {
const name = request.query.name;
if (!name) {
response.status(400).send('ERROR you must supply a name :(');
}
response.send(`hello ${name}`);
});
$ firebase deploy --only functions
Saya berharap fungsi tersebut berhasil diterapkan ke proyek firebase yang dipilih.
Saya menerima kesalahan ini: "Tidak dapat memahami target yang akan diterapkan. Periksa apakah Anda menetapkan target yang valid jika Anda menggunakan flag --only atau --except. Jika tidak, periksa firebase.json Anda untuk memastikan bahwa proyek Anda diinisialisasi untuk fitur yang diinginkan ."
Saya mengatasinya tetapi sekarang saya menerima ini ketika saya mencoba untuk menyebarkan:
../node_modules/@types/cordova/index.d.ts(35,58): error TS2304: Cannot find name 'Event'.
../node_modules/@types/cordova/index.d.ts(36,52): error TS2304: Cannot find name 'Event'.
../node_modules/@types/cordova/index.d.ts(37,53): error TS2304: Cannot find name 'Event'.
../node_modules/@types/cordova/index.d.ts(38,57): error TS2304: Cannot find name 'Event'.
../node_modules/@types/cordova/index.d.ts(39,57): error TS2304: Cannot find name 'Event'.
../node_modules/@types/cordova/index.d.ts(40,59): error TS2304: Cannot find name 'Event'.
../node_modules/@types/cordova/index.d.ts(41,62): error TS2304: Cannot find name 'Event'.
../node_modules/@types/cordova/index.d.ts(42,60): error TS2304: Cannot find name 'Event'.
../node_modules/@types/cordova/index.d.ts(43,63): error TS2304: Cannot find name 'Event'.
../node_modules/@types/cordova/index.d.ts(44,61): error TS2304: Cannot find name 'Event'.
../node_modules/@types/cordova/index.d.ts(46,61): error TS2304: Cannot find name 'Event'.
../node_modules/@types/cordova/index.d.ts(47,55): error TS2304: Cannot find name 'Event'.
../node_modules/@types/cordova/index.d.ts(48,56): error TS2304: Cannot find name 'Event'.
../node_modules/@types/cordova/index.d.ts(49,60): error TS2304: Cannot find name 'Event'.
../node_modules/@types/cordova/index.d.ts(50,60): error TS2304: Cannot find name 'Event'.
../node_modules/@types/cordova/index.d.ts(51,62): error TS2304: Cannot find name 'Event'.
../node_modules/@types/cordova/index.d.ts(52,65): error TS2304: Cannot find name 'Event'.
../node_modules/@types/cordova/index.d.ts(53,63): error TS2304: Cannot find name 'Event'.
../node_modules/@types/cordova/index.d.ts(54,66): error TS2304: Cannot find name 'Event'.
../node_modules/@types/cordova/index.d.ts(55,64): error TS2304: Cannot find name 'Event'.
../node_modules/@types/cordova/index.d.ts(57,51): error TS2304: Cannot find name 'Event'.
../node_modules/@types/cordova/index.d.ts(58,54): error TS2304: Cannot find name 'Event'.
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.
Mungkinkah ini ada hubungannya dengan TSLint?
saya tambahkan
"files": [
"node_modules/typescript/lib/lib.es6.d.ts"
],
"exclude": [
"node_modules"
]
ke file tsconfig saya di functions dan itu sepertinya berhasil. Beri tahu saya jika tidak apa-apa.
Saya tidak melihat mengapa itu akan menjadi masalah. Senang Anda bisa menyelesaikannya.
Komentar yang paling membantu
saya tambahkan
ke file tsconfig saya di functions dan itu sepertinya berhasil. Beri tahu saya jika tidak apa-apa.