pring.ts
pring.ts copied to clipboard
Deployment error. Function load error
I am trying to deploy my cloud function after updating pring and this is wha I get.
Pring version : 0.22.0
Function load error: Code in file lib/index.js can't be loaded. Is there a syntax error in your code? Detailed stack trace: /user_code/node_modules/pring/lib/batch.js:110 async commit() { ^^^^^^
SyntaxError: Unexpected identifier
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:549:28)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
at Module.require (module.js:504:17)
at require (internal/module.js:20:19)
at Object.
I was trying to use Pring with cloud function when this error occurred. Everything built fine and lint ran well.
Thanks.
I fixed.
- Please remove
firebase-admin
from yourpackage.json
- Please declare Admin from Pring.
- Please import the declared model after initialization.
for example.
import * as functions from 'firebase-functions';
import * as Pring from "pring"
const admin = Pring.Admin
admin.initializeApp()
const app = admin.app()
Pring.initialize(app.firestore(), admin.firestore.FieldValue.serverTimestamp())
import { User } from "./user"
export const userSave = functions.https.onRequest(async (request, response) => {
const user: User = new User()
await user.save()
});
How can I guarantee that the version of firebase-admin
Prin is using is the latest version. It ties everything to Pring.
This time firebase-admin now includes @ google-cloud / firestore
so this is the implementation
In the future we will change to implementation that does not depend on firebase-admin.
@jerryOkafor I released 0.23.0 not dependent on Admin.
Ok, I will check that, but it pointed to the async commit()
function in batch.ts
.
It is still happening even after upgrading to the latest version.
@jerryOkafor Hi.
I create pring-admin
https://github.com/1amageek/pring-admin.ts
try this