Search code examples
node.jsherokuecmascript-6gulpheroku-cli

nodejs project transfert mac to mac get error on second mac when sending to heroku import express from 'express'


I have a problem when transfering my nodeJs api from my personal mac to my work mac. The error occur when I send the app to heroku server it is send succesfully but I get an error which is :

import express from 'express';
SyntaxError: Unexpected token import

I regularly make some local update and then send them to heroku server I do not get any error from my previous mac

the starting process is not the same on my previous mac it was:npm start

and the new one is node server/index.js

I tried several things:

change procfile value from:web: node server/index.js to web: node server/app.js and web: npm start

I have put "heroku-postbuild": "npm run build" in my package.json

Before every export to heroku I do: heroku repo:purge_cache -a my-app

I also git commit using --allow-empty to export my project I've used :

git push heroku master
heroku git:clone -a APP-NAME

and then : npm install

the version of npm is the same in both computer node v8.11.1 npm 5.6.0

heroku version for both too : heroku/7.19.4 darwin-x64 node-v11.3.0

none of this change has been successfull

note that I am looking for a solution to resolve it and do not want to use the old syntax like const express = require("express")


Solution

  • I solved it by installing esm it is very easy tool see the doc for more info