Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deployment error. Function load error #35

Open
jerryOkafor opened this issue Oct 30, 2018 · 8 comments
Open

Deployment error. Function load error #35

jerryOkafor opened this issue Oct 30, 2018 · 8 comments

Comments

@jerryOkafor
Copy link

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
Copy link
Author

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

@1amageek
Copy link
Owner

1amageek commented Nov 1, 2018

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()

});

@jerryOkafor
Copy link
Author

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

@1amageek
Copy link
Owner

1amageek commented Nov 1, 2018

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
Copy link
Owner

1amageek commented Nov 1, 2018

@jerryOkafor I released 0.23.0 not dependent on Admin.

@jerryOkafor
Copy link
Author

jerryOkafor commented Nov 1, 2018

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

@jerryOkafor
Copy link
Author

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

@1amageek
Copy link
Owner

1amageek commented Nov 3, 2018

@jerryOkafor
Hi.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants