question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Switching from index.js to index.mjs requires a restart

See original GitHub issue

Describe the issue When you start Sandbox and a route has an index.js file, renaming that to index.mjs will cause that route to fail with a cannot a “Lambda handler not found” error until Sandbox is restarted. The reverse (starting up with index.mjs and renaming to index.js) also triggers the same issue.

Steps to reproduce

  1. Create a new Architect project, add a single HTTP route and start Sandbox.
  2. Rename index.js to index.mjs and make the necessary tweaks to be an ESM handler function.
  3. Attempt to load the route in the browser.

Expected behavior Flipping from CommonJS to ESM doesn’t require a Sandbox restart.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ryanblockcommented, Sep 8, 2022

Ok, ESM handler provisioning by default is now live in 10.6, hopefully this helps resolve the root issue at hand here!

0reactions
ryanblockcommented, Sep 7, 2022

Ok, getting pretty close! I think this could land as soon as tomorrow. Primary PRs here if you (or anyone) want to futz around with local patching:

Read more comments on GitHub >

github_iconTop Results From Across the Web

Instead change the require of index.js, to a dynamic import ...
I did npm i node-fetch@2.6.1, it seems like it fixed it, then i wrote node utils/nftport/uploadFiles.js in the terminal (dont know the proper ......
Read more >
Pinia not working · Issue #6623 · nuxt/framework - GitHub
ERROR Cannot start nuxt: Cannot find module 'pinia/dist/pinia.mjs' 10:34:41 Require stack: - /home/nuxt3/index.js Require stack: - index.js ...
Read more >
How To Restart Your Node.js Apps Automatically with nodemon
Step 1 — Installing nodemon. First, you will need to install nodemon on your machine. Install the utility either globally or locally on...
Read more >
Automatically restart Node.js apps with Nodemon
The essential tutorial for Nodemon, a utility for Node.js applications that monitors for changes and automatically restarts the server.
Read more >
Upgrade your Node app: From CommonJS to ES Modules
I recently ported a midsized, vanilla Node.js app from CommonJS to ES Modules. Here's what I learned and how you can modernize your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found