I’m hosting a nodejs project on server, that uses ES6 syntax, and I used babel-cli to compile it. I don't have any problem in my localhost, but when i host it I get this error:
import express from 'express';^^^^^^^SyntaxError: Unexpected identifier
my node version is v10.16.0
package.json:
{ "name": "example", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "start": "nodemon ./index.js --exec babel-node -e js" }, "author": "", "license": "ISC", "dependencies": { "bcrypt": "^3.0.2", "express": "^4.16.3", "jsonwebtoken": "^8.4.0", "mongodb": "^3.1.6", "mongoose": "^5.3.1", "nodemailer": "^6.2.1", "nodemon": "^1.18.4", "randomstring": "^1.1.5", "shortid": "^2.2.14" }, "devDependencies": { "babel-cli": "^6.26.0", "babel-preset-env": "^1.7.0", "babel-preset-stage-0": "^6.24.1" } } and for .babelrc:
{ "presets": [ "env", "stage-0" ] }
import express from 'express'; ^^^^^^^ SyntaxError: Unexpected identifier at Module._compile (internal/modules/cjs/loader.js:721:23) at Object.Module._extensions..js (internal/modules /cjs/loader.js:787:10) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules/cjs/loader.js:585:3) at Function.Module.runMain (internal/modules/cjs/loader.js:829:12) at startup (internal/bootstrap/node.js:283:19) at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)