node.js - Deploy node server on heroku and receive "SyntaxError: Unexpected token import" -
i have server written in node.js using node 6.10.2 , ecmascript. want upload heroku, locally when rung server "npm start" server starts without problem, on heroku recevied following error
import express 'express'; syntaxerror: unexpected token import
how can fix error?
thanks
you have 2 options:
- use
require()
instead ofimport
- transpile code
node doesn't support import
keyword. in node import modules require()
function. example can change this:
import express 'express';
to this:
const express = require('express');
or can transpile code e.g. babel if want use import
. see:
Comments
Post a Comment