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

Error: Failed to load function definition from source: Failed to generate manifest from function source: SyntaxError: Cannot use import statement outside a module #1462

Open
frank-bee opened this issue Nov 2, 2023 · 7 comments

Comments

@frank-bee
Copy link

frank-bee commented Nov 2, 2023

Describe the bug
When deploying a function (derivative) , I get this error during deploy:
(Did not change a lot , no import statements, in my code)

12:01:56:56  stdout: {"error":{"code":1,"killed":false,"signal":null,"cmd":"cd build/functionBuilder/builds/1698922843459; yarn deploy --project bedstories-8ebd2 --only functions"},"stdout":"$ echo 'n
' | firebase deploy --interactive --project bedstories-8ebd2 --only functions

=== Deploying to 'bedstories-8ebd2'...

i  deploying functions
i  functions: preparing codebase default for deployment
i  functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i  functions: ensuring required API cloudbuild.googleapis.com is enabled...
i  artifactregistry: ensuring required API artifactregistry.googleapis.com is enabled...
✔  functions: required API cloudfunctions.googleapis.com is enabled
✔  functions: required API cloudbuild.googleapis.com is enabled
✔  artifactregistry: required API artifactregistry.googleapis.com is enabled

Error: Failed to load function definition from source: Failed to generate manifest from function source: SyntaxError: Cannot use import statement outside a module
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
","stderr":"error Command failed with exit code 1.
"}

Rowy Run version
latest (I work with the browser)

@shamsmosowi
Copy link
Member

Hi @frank-bee can you share your table schema, i can take look

@frank-bee
Copy link
Author

oh nice!
this is the table
https://rowy.app/p/bedstories-8ebd2/table/stories

@frank-bee
Copy link
Author

the column I changed was "Stories". but I think I reverted the changes and still get the error.
maybe one of my imported packages changed.
I use chatgpt API and a text2speach api from 11labs ( in some other column)

thanks for helping me @shamsmosowi

@frank-bee
Copy link
Author

@shamsmosowi
it seems to be in the azure lib in the derivative in the url column:

stderr: /home/node/app/build/functionBuilder/builds/1699084535870/node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/microsoft.cognitiveservices.speech.sdk.js:3
import { ConsoleLoggingListener } from "./src/common.browser/Exports";
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at internalCompileFunction (node:internal/vm:73:18)
    at wrapSafe (node:internal/modules/cjs/loader:1178:20)
    at Module._compile (node:internal/modules/cjs/loader:1220:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at Object.<anonymous> (/home/node/app/build/functionBuilder/builds/1699084535870/src/derivatives/url.js:100:13)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
error Command failed with exit code 1.

@frank-bee
Copy link
Author

I moved the import statement ( not the one in the error message but the one were I import the surrounding package) inside a function, no it works

@frank-bee frank-bee reopened this Nov 4, 2023
@frank-bee
Copy link
Author

I tested it again: issue is still there, now during runtime, not deplyoment.

@frank-bee
Copy link
Author

@shamsmosowi this issue and #1471 both had todo with this azure package 'microsoft-cognitiveservices-speech-sdk'.
When importing this ( with require) , this messes up my complete rowy function ( of even the other functions of other tables?).
below some sample code how you could test this.

What I do to temp. fix this, I fixed the package.json, downgrading to "microsoft-cognitiveservices-speech-sdk": "1.32.0",
How can I do this with rowy?

sample code for reproducing this issue

function synthesizeSpeech(logging) {
    var sdk = require("microsoft-cognitiveservices-speech-sdk");

    const speechConfig = sdk.SpeechConfig.fromSubscription("..", "eastus");
    const speechSynthesizer = new sdk.SpeechSynthesizer(speechConfig);

    speechSynthesizer.speakTextAsync(
        "I'm excited to try text to speech",
        result => {
          logging.log("ok");
            speechSynthesizer.close();
            return result.audioData;
        },
        error => {
            logging.log(error);
            speechSynthesizer.close();
        });
}

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