brefphp / bref

Serverless PHP on AWS Lambda
https://bref.sh
MIT License
3.15k stars 365 forks source link

Serverless commands failing with latest Laravel and bref plugin #1540

Closed briankiewel closed 1 year ago

briankiewel commented 1 year ago

Description:

I followed this helpful guide from @mnapoli and am running into an error with the latest version of Laravel. Whenever I try to run any serverless commands in the application directory, I get the error below. It seems like it may be related to a recent change in Laravel where "type": "module", was added to the package.json file. If I remove that line from package.json, serverless will run fine, but it breaks the asset compilation in Laravel. If I remove the bref plugin from serverless.yml, serverless will run fine (but throw an error because the PHP runtime isn't valid, which makes sense).

I've tried this on MacOS and Ubuntu 20.04, and I've tried with Node 12, 14, and 16.

~/Code/serverless >> serverless info
Environment: darwin, node 16.16.0, framework 3.30.1 (standalone), plugin 6.2.3, SDK 4.3.2
Docs:        docs.serverless.com
Support:     forum.serverless.com
Bugs:        github.com/serverless/serverless/issues

Error:
TypeError: Invalid host defined options
    at /snapshot/serverless/lib/utils/import-esm.js:5:54
    at /snapshot/serverless/lib/utils/require-with-import-fallback.js:9:44
    at PluginManager.requireServicePlugin (/snapshot/serverless/lib/classes/plugin-manager.js:171:14)
    at PluginManager.resolveServicePlugins (/snapshot/serverless/lib/classes/plugin-manager.js:198:29)
    at PluginManager.loadAllPlugins (/snapshot/serverless/lib/classes/plugin-manager.js:136:47)
    at Serverless.init (/snapshot/serverless/lib/serverless.js:146:30)
    at async /snapshot/serverless/scripts/serverless.js:614:7
mnapoli commented 1 year ago

Thanks for the report, that's super annoying! I'll try to look into it soon!

Maybe it's just a matter of changing index.js into index.cjs in this repository 🤔

mnapoli commented 1 year ago

I have opened #1546 to fix this