Closed cedric-vermeulen closed 2 days ago
Thanks a lot for the detailed report @cedric-vermeulen ... We really appreciate such reports ❤️ ... I'll look into this.
I just wanted to +1 to this. I tried running a local command that worked in v3 and got the following stacktrace:
npm exec sls invoke local --function fireball --stage prod --data {"function": "nico"}
Warning: Using serverless deploy -f option only updates the function code and will not update CloudFormation stack (env variables included).
✖ ReferenceError: module is not defined in ES module scope
This file is being treated as an ES module because it has a '.js' file extension and '/Users/nicolashinderling/dev/emerge-pnpm-on-hold/backend/services/emerge/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
at file:///Users/nicolashinderling/dev/emerge-pnpm-on-hold/backend/services/emerge/.serverless/build/src/fireball/fireball.js:224:2761
at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
at async loadModule (file:///Users/nicolashinderling/.serverless/releases/4.1.5/package/dist/sf-core.js:1025:9923)
at async AwsInvokeLocal.invokeLocalNodeJs (file:///Users/nicolashinderling/.serverless/releases/4.1.5/package/dist/sf-core.js:1025:9253)
at async PluginManager.runHooks (file:///Users/nicolashinderling/.serverless/releases/4.1.5/package/dist/sf-core.js:1028:9294)
at async PluginManager.invoke (file:///Users/nicolashinderling/.serverless/releases/4.1.5/package/dist/sf-core.js:1028:10064)
at async PluginManager.run (file:///Users/nicolashinderling/.serverless/releases/4.1.5/package/dist/sf-core.js:1028:10788)
at async Serverless.run (file:///Users/nicolashinderling/.serverless/releases/4.1.5/package/dist/sf-core.js:1035:10442)
at async runFramework (file:///Users/nicolashinderling/.serverless/releases/4.1.5/package/dist/sf-core.js:1079:2314)
at async route (file:///Users/nicolashinderling/.serverless/releases/4.1.5/package/dist/sf-core.js:1088:14692)
at async Object.run2 [as run] (file:///Users/nicolashinderling/.serverless/releases/4.1.5/package/dist/sf-core.js:1088:15090)
at async run3 (file:///Users/nicolashinderling/.serverless/releases/4.1.5/package/dist/sf-core.js:1088:16324)
✖ Exception encountered when loading /Users/nicolashinderling/dev/emerge-pnpm-on-hold/backend/services/emerge/.serverless/build/src/fireball/fireball
ServerlessError2: Exception encountered when loading /Users/nicolashinderling/dev/emerge-pnpm-on-hold/backend/services/emerge/.serverless/build/src/fireball/fireball
at AwsInvokeLocal.invokeLocalNodeJs (file:///Users/nicolashinderling/.serverless/releases/4.1.5/package/dist/sf-core.js:1025:9347)
at async PluginManager.runHooks (file:///Users/nicolashinderling/.serverless/releases/4.1.5/package/dist/sf-core.js:1028:9294)
at async PluginManager.invoke (file:///Users/nicolashinderling/.serverless/releases/4.1.5/package/dist/sf-core.js:1028:10064)
at async PluginManager.run (file:///Users/nicolashinderling/.serverless/releases/4.1.5/package/dist/sf-core.js:1028:10788)
at async Serverless.run (file:///Users/nicolashinderling/.serverless/releases/4.1.5/package/dist/sf-core.js:1035:10442)
at async runFramework (file:///Users/nicolashinderling/.serverless/releases/4.1.5/package/dist/sf-core.js:1079:2314)
at async route (file:///Users/nicolashinderling/.serverless/releases/4.1.5/package/dist/sf-core.js:1088:14692)
at async Object.run2 [as run] (file:///Users/nicolashinderling/.serverless/releases/4.1.5/package/dist/sf-core.js:1088:15090)
at async run3 (file:///Users/nicolashinderling/.serverless/releases/4.1.5/package/dist/sf-core.js:1088:16324)
For help, try the following:
• Run the command again with the "--debug" option
• Run "serverless support"
• Review the docs: https://www.serverless.com/framework/docs/
npm verb exit 1
npm verb code 1
@eahefnawy was this change released? I tried running npx serverless update
and am still seeing errors when running my local invoke command (slightly different error message but still similar... I can post the error logs if needed)
Yeah it was released. What's the new error you're seeing? 🤔
Hey @eahefnawy my apologies, I had something messed up locally. I re-setup my local and my npx invoke local is working now! Sorry about that!
Great to hear! 🙌
Issue description
I did update to serverless V4 with success. If running serverless dev, I have no issue. But when i try to run
serverless invoke local -f handler
it does fail with this kind of issue:I could pinpoint the exact location and fix.
In .serverless\releases\4.1.5\package\dist\sf-core.js Line 1025 i did change:
path47.join(this.serverless.serviceDir,this.options.extraServicePath||"",handlerPath)
topath47.join("file://",this.serverless.serviceDir,this.options.extraServicePath||"",handlerPath)
Of course it's a bit of a hack, I've seen in the file that we do handle file system more cleanly but I needed a quick fix.
I hope this is enough informations to help you fix the issue.
Service Overview
Service Overview
Service Path
E:\kkk\gestion\gestion.services\project-manager
Service Config
Thank you, Have a nice day,
Context
No response