GithubHelp home page GithubHelp logo

Comments (8)

danielleadams avatar danielleadams commented on June 2, 2024 7

Hi @luax, this is on my list, but unfortunately haven't gotten around to it yet. For what it's worth, I would like to get this fixed as soon as possible since I think this is important to support, but since Node.js Language Metrics is a beta feature, it becomes a little harder to prioritize.

Nonetheless, I will keep this issue updated with my progress.

from heroku-nodejs-plugin.

danielleadams avatar danielleadams commented on June 2, 2024

Hi @luax - this is the right place for this bug. I will investigate this and report back. It has to do with the plugin's use of require when ES Modules have been enabled. The plugin will need to do ES module-style imports when it's enabled, so I need to figure out what that looks like.

from heroku-nodejs-plugin.

luax avatar luax commented on June 2, 2024

Thanks @danielleadams! I also created a support ticket.

Here is a reproducible example:

  • package.json

    {
      "name": "heroku-test",
      "version": "1.0.0",
      "main": "index.js",
      "license": "MIT",
      "type": "module",
      "engines": {
        "node": "14.x"
      },
      "dependencies": {
        "express": "4.17.1"
      }
    }
    
  • index.js

    import express from 'express';
    
    const app = express()
    const port = process.env.PORT || 3000
    
    app.get('/', (req, res) => res.send('Hello World!'))
    
    app.listen(port, () => console.log(`Example app listening at http://localhost:${port}`))
    

from heroku-nodejs-plugin.

luax avatar luax commented on June 2, 2024

Sorry but are there any news on when this might be solved @danielleadams?

My current workaround is booting with:

web: echo { \"type\": \"commonjs\" } > /app/.heroku/heroku-nodejs-plugin/package.json && node index.js

Or not use native modules as it seems risky to add things to /app/.heroku on the fly.

Thanks!

from heroku-nodejs-plugin.

imargulyan avatar imargulyan commented on June 2, 2024

I face the same problem on a Hobby Dyno at Heroku. It is definitely an issue with heroku-nodejs-plugin since I dont face it on a Free Dyno which doesnt have metrics plugin but running the same code. Node v14.5

from heroku-nodejs-plugin.

lblo avatar lblo commented on June 2, 2024

Hi,
I'm also having the same issue after migrating my Node project to "type": "module" and killing all the require in my project...
I'll try luax's solution.

from heroku-nodejs-plugin.

ahmadyousef1125 avatar ahmadyousef1125 commented on June 2, 2024

Can confirm also.
When turning on this switch:
image

and setting "type": "module" in the package.json, then the app crashes with the mentioned error.

from heroku-nodejs-plugin.

danielleadams avatar danielleadams commented on June 2, 2024

The fix will go out with the next release.

from heroku-nodejs-plugin.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.