pring.ts icon indicating copy to clipboard operation
pring.ts copied to clipboard

Deployment error. Function load error

Open jerryOkafor opened this issue 6 years ago • 8 comments

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. (/user_code/node_modules/pring/lib/index.js:4:17)

jerryOkafor avatar Oct 30 '18 17:10 jerryOkafor

I was trying to use Pring with cloud function when this error occurred. Everything built fine and lint ran well.

jerryOkafor avatar Oct 31 '18 08:10 jerryOkafor

Thanks.

I fixed.

  • Please remove firebase-admin from your package.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()

});

1amageek avatar Nov 01 '18 07:11 1amageek

How can I guarantee that the version of firebase-admin Prin is using is the latest version. It ties everything to Pring.

jerryOkafor avatar Nov 01 '18 08:11 jerryOkafor

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.

1amageek avatar Nov 01 '18 09:11 1amageek

@jerryOkafor I released 0.23.0 not dependent on Admin.

1amageek avatar Nov 01 '18 09:11 1amageek

Ok, I will check that, but it pointed to the async commit() function in batch.ts.

jerryOkafor avatar Nov 01 '18 09:11 jerryOkafor

It is still happening even after upgrading to the latest version.

jerryOkafor avatar Nov 01 '18 17:11 jerryOkafor

@jerryOkafor Hi.

I create pring-admin https://github.com/1amageek/pring-admin.ts try this

1amageek avatar Nov 03 '18 16:11 1amageek