Deploy Node application in Heroku with ES6 modules?

Asked

Viewed 49 times

0

Speak, devs!

Following...

I would like to know how to deploy a Nodejs application using ES6 Modules

In my package.json I am using so:

"type": "module",
...
"scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "dev": "nodemon --es-module-specifier-resolution=node src",
    "start": "--es-module-specifier-resolution=node src"
  },

For the nodemon to recognize the modules I had to add content --es-module-specifier-resolution=node in dev

For PM2 reconhcer need to add node_ags node_args: "--es-module-specifier-resolution=node", to be able to recognize the modules

Following in the footsteps of that document, I came across the command heroku local web

Where I execute the command I have the following return

'--es-module-specifier-resolution' n�o � reconhecido como um comando interno

But if I take the --es-module-specifier-resolution=node start it does not recognize the modules

 Error [ERR_MODULE_NOT_FOUND]: Cannot find module

How do I add this node or make Heroku accept modules?

  • Is your start script correct? The word is not missing node or nodemon before the arguments?

  • What is the value of the property type in his package.json?

  • It must be the "start" that is wrong

  • @Luizfelipe the value of the type property is module

  • @Guilhermenascimento as it is, is the start that I need to know the correct way how Heroku recognizes

  • @Danizavtz Right! That’s right! Something was missing before the arguments.. It was Node

  • Oops, blz. I voted to close because it was just a mistake, how nice that it was solved.

  • Blz! I’ve seen questions in the forum at Universities that are not answered

Show 3 more comments

1 answer

1


In his file package.json you’re forgetting to put the word node or nodemon.

Notice carefully the following line you are declaring:

 "start": "--es-module-specifier-resolution=node src"

As it should be:

 "start": "node --es-module-specifier-resolution=node src"

Browser other questions tagged

You are not signed in. Login or sign up in order to post.