Error: Failed to load function definition from source: Failed to generate manifest from function source: SyntaxError: Cannot use import statement outside a module
frank-bee opened this issue · 7 comments
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)
Hi @frank-bee can you share your table schema, i can take look
oh nice!
this is the table
https://rowy.app/p/bedstories-8ebd2/table/stories
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
@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.
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
I tested it again: issue is still there, now during runtime, not deplyoment.
@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();
});
}