I am studying Full-Stack Redux on the following page: http://teropa.info/blog/2015/09/10/full-stack-redux-tutorial.html#introducing-the-redux-store
After created new server using socket-io in server.js and run app using babel-node, I got the following error:
/home/ubuntu/workspace/src/server.js:15
var io = new _socket2.default().attach(8090);
^
TypeError: _socket2.default is not a function
at startServer (server.js:4:16)
at Object.<anonymous> (index.js:5:1)
at Module._compile (module.js:409:26)
at loader (/home/ubuntu/workspace/node_modules/babel-cli/node_modules/babel-register/lib/node.js:126:5)
at Object.require.extensions.(anonymous function) [as .js] (/home/ubuntu/workspace/node_modules/babel-cli/node_modules/babel-register/lib/node.js:136:7)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
at /home/ubuntu/workspace/node_modules/babel-cli/lib/_babel-node.js:161:27
at Object.<anonymous> (/home/ubuntu/workspace/node_modules/babel-cli/lib/_babel-node.js:162:7)
This is the code of server.js
import Server from 'socket.io';
export default function startServer() {
const io = new Server().attach(8090);
};
This is the code of index.js
import makeStore from './src/store';
import startServer from './src/server';
export const store = makeStore();
startServer();
and this is package.json file:
{
"name": "chat-example",
"version": "0.0.0",
"description": "A chat example to showcase how to use `socket.io` with a static `express` server with `async` for control flow.",
"main": "server.js",
"repository": "",
"author": "Mostafa Eweda <mo.eweda#gmail.com>",
"scripts": {
"start": "babel-node index",
"test": "mocha --compilers js:babel-core/register --require ./test/test_helper.js --recursive",
"test:watch": "npm run test -- --watch"
},
"devDependencies": {
"babel-cli": "^6.6.5",
"babel-core": "^6.7.2",
"babel-preset-es2015": "^6.6.0",
"chai": "^3.5.0",
"chai-immutable": "^1.5.3",
"mocha": "^2.4.5"
},
"babel": {
"presets": [
"es2015"
]
},
"dependencies": {
"async": "~0.2.8",
"express": "~3.2.4",
"immutable": "^3.7.6",
"redux": "^3.3.1",
"socket.io": "^0.9.17"
}
I did exactly the same as what was written on the page. Please give me suggestions on this case. Thanks
I found the solution for this problem, I answer here in case somebody need it.
I believe socket.io no longer uses attach function. Instead they use the following code to create socket server:
const io = Server(8090);
You should change socket.io version to at least 1.4.5: it will be fine!
Please refer to the original source code: https://github.com/teropa/redux-voting-server/blob/master/package.json
Good luck!
In your server.js
import Server from "socket.io";
const startServer = port => {
console.log(`Listening on ${port}`);
const io = new Server().attach(port);
};
export default startServer;
In your index.js
import makeStore from "./src/store";
import startServer from "./src/server";
export const store = makeStore();
startServer(8090);
Related
Problem:
When I run this command: npx ts-node-dev --respawn --transpile-only index.ts, I get this error:
rob#hi~/dev/robrendellwebsite$ npx ts-node-dev --respawn --transpile-only index.ts
[INFO] 06:23:55 ts-node-dev ver. 2.0.0 (using ts-node ver. 10.9.1, typescript ver. 4.8.4)
Compilation error in /home/rob/dev/robrendellwebsite/index.ts
Error: Must use import to load ES Module: /home/rob/dev/robrendellwebsite/index.ts
at Object.<anonymous> (/home/rob/dev/robrendellwebsite/index.ts:1:7)
at Module._compile (node:internal/modules/cjs/loader:1159:14)
at Module._compile (/home/rob/dev/robrendellwebsite/node_modules/source-map-support/source-map-support.js:568:25)
at Module.m._compile (/tmp/ts-node-dev-hook-6490566241511986.js:69:33)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
at require.extensions..jsx.require.extensions..js (/tmp/ts-node-dev-hook-6490566241511986.js:114:20)
at require.extensions.<computed> (/tmp/ts-node-dev-hook-6490566241511986.js:71:20)
at Object.nodeDevHook [as .ts] (/home/rob/dev/robrendellwebsite/node_modules/ts-node-dev/lib/hook.js:63:13)
at Module.load (node:internal/modules/cjs/loader:1037:32)
at Function.Module._load (node:internal/modules/cjs/loader:878:12)
[ERROR] 06:23:55 Error: Must use import to load ES Module: /home/rob/dev/robrendellwebsite/index.ts
What I've tried:
adding "type":"module" to my package.json:
Here's my package.json
{
"name": "robrendellwebsite",
"version": "1.0.0",
"description": "nodejs backend api for robrendellwebsite",
"main": "index.js",
"engines": {
"node": "18.x"
},
"type": "module",
"scripts": {
"start": "node dist/index.js",
"build": "tsc",
"postinstall": "npm run build",
"dev:slow": "ts-node index.ts",
"dev": "ts-node-dev --respawn --pretty --transpile-only index.ts",
"test": "jest",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --ext .ts --fix",
"update-common": "npm install robrendellwebsite-common"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Robert-Rendell/robrendellwebsite.git"
},
"author": "Robert Rendell",
"license": "ISC",
"bugs": {
"url": "https://github.com/Robert-Rendell/robrendellwebsite/issues"
},
"homepage": "https://github.com/Robert-Rendell/robrendellwebsite#readme",
"devDependencies": {
"#babel/core": "^7.19.6",
"#babel/preset-env": "^7.19.4",
"#babel/preset-typescript": "^7.18.6",
"#types/cors": "^2.8.12",
"#types/express": "^4.17.14",
"#types/jest": "^27.0.2",
"#types/morgan": "~1.9.3",
"#types/node": "^18.11.8",
"#types/uuid": "^8.3.1",
"#typescript-eslint/eslint-plugin": "~5.2.0",
"#typescript-eslint/parser": "~5.2.0",
"babel-jest": "^27.3.1",
"googleapis": "^108.0.1",
"husky": "^8.0.1",
"jest": "^27.3.1",
"ts-node": "^10.9.1",
"ts-node-dev": "^2.0.0",
"typescript": "^4.8.4"
},
"dependencies": {
"aws-sdk": "^2.1243.0",
"cors": "^2.8.5",
"dotenv": "^16.0.3",
"express": "^4.18.2",
"express-rate-limit": "^6.6.0",
"helmet": "^6.0.0",
"morgan": "~1.10.0",
"robrendellwebsite-common": "^1.2.0",
"uuid": "^8.3.2"
}
}
Here's my index.ts:
import { config } from 'dotenv';
import express from 'express';
import cors from 'cors';
import morgan from 'morgan';
import { HomePage } from './src/pages/home/home.page';
import SudokuAPI from './src/pages/sudoku/sudoku.page';
import TechTestUniDataAPI from './src/pages/technical-tests/uni-data-291121/uni-data-291121.page';
import { NatureRouting } from './src/pages/photos-ive-taken/nature/nature.routing';
import { WildFlowersPage } from './src/pages/photos-ive-taken/nature/pages/wild-flowers.page';
import { ArachnidsPage } from './src/pages/photos-ive-taken/nature/pages/arachnids.page';
import { InsectsPage } from './src/pages/photos-ive-taken/nature/pages/insects.page';
import { LichenPage } from './src/pages/photos-ive-taken/nature/pages/lichen.page';
import { FungiPage } from './src/pages/photos-ive-taken/nature/pages/fungi.page';
config();
if (!process.env.PORT) {
process.exit(1);
}
// Heroku exposes PORT env var by default
const PORT = process.env.PORT || 80;
const app = express();
// app.use(helmet());
app.use(cors());
app.use(morgan('combined'));
app.use(express.json());
// === Rate Limiting =======================
// only if you're behind a reverse proxy
// eg. (Heroku, Bluemix, AWS if you use an ELB, custom Nginx setup, etc)
app.enable('trust proxy');
// const limiter = RateLimit({
// windowMs: 15 * 60 * 1000, // 15 minutes
// max: 100, // limit each IP to 100 requests per windowMs
// });
// apply to all requests
//app.use(limiter);
// =========================================
app.listen(PORT, () => {
console.log(`Listening on port ${PORT}`);
});
// === Routes =========================================
app.get('/', HomePage);
app.get('/', HomePage);
app.get(NatureRouting.WildFlowers, WildFlowersPage);
app.get(NatureRouting.Arachnids, ArachnidsPage);
app.get(NatureRouting.Insects, InsectsPage);
app.get(NatureRouting.Lichen, LichenPage);
app.get(NatureRouting.Fungi, FungiPage);
app.get(SudokuAPI.Routes.getSudoku, SudokuAPI.getSudoku);
app.get(SudokuAPI.Routes.getSudokuLeaderboard, SudokuAPI.getSudokuLeaderboard);
app.post(SudokuAPI.Routes.postSudokuList, SudokuAPI.postSudokuList);
app.post(SudokuAPI.Routes.postSubmission, SudokuAPI.postSubmission);
app.post(SudokuAPI.Routes.postGenerateSudoku, SudokuAPI.generateSudoku);
app.post(SudokuAPI.Routes.postGenerateSudokuCallback, SudokuAPI.generateSudokuCallback);
app.get(TechTestUniDataAPI.Routes.getDashboardGraphs, TechTestUniDataAPI.getDashboardGraphs);
The error in my case was to do with a dependency: "robrendellwebsite-common": "^1.2.0", which wasn't configured correctly and caused transpiled JavaScript to be different to the project that imported it. Didn't get to the root cause exactly, but the answer in this case was to rollback. This is a lesson in committing small changes at a time so you can easily isolate where you went wrong.
For some context, I'm trying to develop apps for Microsoft Teams. So I decided to follow the 'Hello World' project but I ran into an issue when generating the app package(a zip file). I'm on Win10
Here are my versions of node and gulp
$ gulp -v
CLI version: 2.2.0
Local version: 4.0.0
$ node -v
v12.14.1
My Error :(
$ gulp
assert.js:374
throw err;
^
AssertionError [ERR_ASSERTION]: Task function must be specified
at Gulp.set [as _setTask] (C:\Users\Comp\source\entitled\msteams-samples-hello-world-nodejs\node_modules\undertaker\lib\set-task.js:10:3)
at Gulp.task (C:\Users\Comp\source\entitled\msteams-samples-hello-world-nodejs\node_modules\undertaker\lib\task.js:13:8)
at Object.<anonymous> (C:\Users\Comp\source\entitled\msteams-samples-hello-world-nodejs\gulpfile.js:17:6)
at Module._compile (internal/modules/cjs/loader.js:955:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
at Module.load (internal/modules/cjs/loader.js:811:32)
at Function.Module._load (internal/modules/cjs/loader.js:723:14)
at Module.require (internal/modules/cjs/loader.js:848:19)
at require (internal/modules/cjs/helpers.js:74:18)
at execute (C:\Users\Comp\AppData\Roaming\npm\node_modules\gulp-cli\lib\versioned\^4.0.0\index.js:36:18) {
generatedMessage: false,
code: 'ERR_ASSERTION',
actual: false,
expected: true,
operator: '=='
}
package.json
{
"name": "msteams-nodejs-hello-world",
"version": "1.0.0",
"description": "Microsoft Teams Node.js Hello World App. Start here to build your first app on the Teams platform.",
"scripts": {
"start": "node src/app.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/OfficeDev/msteams-samples-hello-world-nodejs.git"
},
"author": "Microsoft Corp.",
"license": "MIT",
"bugs": {
"url": "https://github.com/OfficeDev/msteams-samples-hello-world-nodejs/issues"
},
"homepage": "https://learn.microsoft.com/en-us/microsoftteams/platform/get-started/get-started-nodejs",
"dependencies": {
"botbuilder": "^3.11.0",
"botbuilder-teams": "^0.1.6",
"config": "^1.28.1",
"express": "^4.16.2",
"faker": "^4.1.0",
"natives": "^1.1.6",
"node": "^10.13.0",
"pug": "^2.0.4"
},
"devDependencies": {
"del": "^3.0.0",
"gulp": "^4.0.0",
"gulp-install": "^1.1.0",
"gulp-zip": "^4.0.0"
}
}
gulpfile.js
var gulp = require('gulp');
var zip = require('gulp-zip');
var del = require('del');
gulp.task('clean', function() {
return del([
'manifest/**/*'
])
});
gulp.task('generate-manifest', function() {
gulp.src(['src/static/images/contoso*', 'src/manifest.json'])
.pipe(zip('helloworldapp.zip'))
.pipe(gulp.dest('manifest'));
});
gulp.task('default', ['clean', 'generate-manifest'], function() {
console.log('Build completed. Output in manifest folder');
});
I've read through some other articles with where I had to downgrade node and gulp but I've had no luck.
gulp.task('generate-manifest', function() {
return gulp.src(['src/static/images/contoso*', 'src/manifest.json']) // change here
.pipe(zip('helloworldapp.zip'))
.pipe(gulp.dest('manifest'));
});
gulp.task('default', gulp.series('clean', 'generate-manifest', function() { // change here
console.log('Build completed. Output in manifest folder');
}));
No need to downgrade gulp or node. You just need to use gulp4 syntax instead of gulp3.
I am using NextJS with typescript, mongo Atlas, mongoose, node and express.
I am getting the following error when I run node pages/server:
I have uploaded my package.json file and have added babel as well
import express from 'express'; ^^^^^^
SyntaxError: Cannot use import statement outside a module
at wrapSafe (internal/modules/cjs/loader.js:1072:16)
at Module._compile (internal/modules/cjs/loader.js:1122:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
at Module.load (internal/modules/cjs/loader.js:1002:32)
at Function.Module._load (internal/modules/cjs/loader.js:901:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
at internal/main/run_main_module.js:18:47
This is my server.js code:
import express from 'express';
import { connect, connection } from 'mongoose';
import morgan from 'morgan';
import path from 'path';
const app = express();
const PORT = process.env.PORT || 8080;
//Success
import routes from './routes/api.tsx';
const MONGODB_URI = 'xxx';
// const routes=require('./routes/api')
connect(MONGODB_URI ||'mongodb://localhost/success', {
useNewUrlParser: true,
useUnifiedTopology: true
});
connection.on('connected', () => {
console.log('Mongoose is connected');
});
const newBlogPost = new BlogPost(data); //instance of the model
app.use(morgan('tiny'));
app.use('/',routes)
app.listen(PORT, console.log(`Server is starting at ${PORT}`));
package.json file
{
"name": "la-sheild",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "next",
"build": "next build",
"start": "babel-node server.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"#types/express": "^4.17.2",
"#types/mongoose": "^5.7.1",
"axios": "^0.19.2",
"concurrently": "^5.1.0",
"express": "^4.17.1",
"mongoose": "^5.9.1",
"morgan": "^1.9.1",
"next": "^9.2.2",
"node": "^13.8.0",
"react": "^16.12.0",
"react-dom": "^16.12.0"
},
"devDependencies": {
"#babel/core": "^7.8.4",
"#babel/preset-env": "^7.8.4",
"#babel/register": "^7.8.3",
"#types/node": "^13.7.4",
"#types/react": "^16.9.21",
"babel-cli": "^6.26.0",
"typescript": "^3.7.5"
},
"proxy": "http://localhost:8080"
}
Since Node v12, you can use either the .mjs extension or set "type": "module" in your package.json.
And you need to run node with the --experimental-modules flag.
node --experimental-modules server.mjs
You can check the SO link
Or you can create .babelrc file in the root of your project.
Add following (and any other babel presets you need, can be added in this file):
{
"presets": ["env"]
}
Install babel-preset-env using
npm install babel-preset-env
npm install babel-cli -g
# OR
yarn add babel-preset-env
yarn global add babel-cli
Now, go to the folder where your server.js file exists and
run using:
babel-node fileName.js
Or you can run using npm start by adding following code to your package.json file:
"scripts": {
"start": "babel-node server.js"
}
There is a tutorial link for Set Up Next.js with a Custom Express Server + Typescript on a medium that will be very helpful for you.
The following solution worked for me;
install needed packages
npm install nodemon #babel/core #babel/node #babel/preset-env -D
create a .babelrc file in the working directory and paste the following in it
{
"presets": [
"#babel/preset-env" ]
}
lastly, add the code below to "scripts" in package.json
"dev": "nodemon —exec babel-node server.js"
where server.js is your file in this case.
Hope this works :)
Here is the solution based on ts-next-express.
npm i --save ts-node
create another config file for express because node is using common.js module but if you check the tsconfig.json you will see this:"module": "esnext"
tsconfig.server.json
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"outDir": "dist",
"noEmit": false
},
"include": ["server"]
}
set the script as follow:
"start": "ts-node --project tsconfig.server.json server.ts"
I was getting same error "SyntaxError: Cannot use import statement outside a module" first i add tye : module but still face another error. Finaly its work for me the issue was this i was running my Driver.js file that why i was getting this issue. i run my Driver.ts file its work ok for me.
enter image description here
But after run my with extenstion .ts file its work.
enter image description here
I had my index.ts importing an exported var from my schema.js file.
I was doing an import inside this schema.js file
It was this second import causing the 'Cannot use import statement outside modules'.
Finally renaming the file from schema.js to schema.ts solved the issue.\
"scripts": {
"start": "babel-node server.js"
}
adding above worked for me
I'm facing an issue when exporting a class in expressJS with ES6 syntax.
My project is a Vue CLI project, with an express JS server.
To convert the express server in ES5 I'm using this script when starting it:
nodemon ./server/index.js --exec babel-node --presets #babel/preset-env
It is working fine until I'm trying to export a class.
class ErrorHandler extends Error {
constructor(statusCode, message) {
super(statusCode, message)
this.statusCode = statusCode
this.message = message
}
}
const handleError = (err, res) => {
if (!err.statusCode) err.statusCode = 500 // Sets a generic server error status code if none is part of the error
const { statusCode, message } = err
res.status(statusCode).json({
status: "error",
statusCode,
message
})
}
export{
ErrorHandler,
handleError
}
This piece of code will failed, and return this error:
export default function _classCallCheck(instance, Constructor) {
^^^^^^
SyntaxError: Unexpected token export
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Module._compile (C:\Users\Romain\Documents\Developement\projector\node_modules\pirates\lib\index.js:99:24)
at Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Object.newLoader [as .js] (C:\Users\Romain\Documents\Developement\projector\node_modules\pirates\lib\index.js:104:7)
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 Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (C:\Users\Romain\Documents\Developement\projector\server\helpers\error.js:10:47)
I tried to delete the handleError function, and it was still not working, but when I tried to delete the ErrorHandler class, everything was fine, so it has to come from the class.
I'm new to Node js AND babel, and after all my research I cannot find what the problem is.
Update Here is the package.json
{
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"server": "nodemon ./server/index.js --exec babel-node --presets #babel/preset-env"
},
"dependencies": {
"axios": "^0.19.0",
"bulma": "^0.7.5",
"connect-history-api-fallback": "^1.6.0",
"core-js": "^2.6.5",
"express": "^4.17.1",
"express-session": "^1.16.2",
"mongodb": "^3.3.2",
"passport": "^0.4.0",
"passport-local": "^1.0.0",
"vue": "^2.6.10",
"vue-router": "^3.0.3",
"vuex": "^3.0.1"
},
"devDependencies": {
"#babel/node": "^7.5.5",
"#babel/preset-env": "^7.5.5",
"#vue/cli-plugin-babel": "^3.10.0",
"#vue/cli-service": "^3.10.0",
"node-sass": "^4.12.0",
"nodemon": "^1.19.1",
"sass-loader": "^7.2.0",
"vue-template-compiler": "^2.6.10"
}
}
And babel.config.js:
module.exports = {
presets: [
'#vue/app',
]
}
I am trying to learn how to make web apps with express, however, I am not really understanding how it sends data to the client side and what express is supposed to do. I am under the impression that express is supposed to send data to the client side then the client side is supposed to display the UI according to the data that was sent. Right now I am trying to render a react component from express using reactDOMServer but I am running into a jsx error saying:
res.send(ReactDOMServer.renderToString(<root />))
SyntaxError: Unexpected token <
I am aware of this post and have tried installing babel for the jsx, but it still gives me this error.
Here is my app.js:
const express = require("express")
const React = require("react")
const ReactDOMServer = require("react-dom/server");
const root = require("./public/root.js");
const app = express();
app.get("/", (req, res) => {
res.send(ReactDOMServer.renderToString(<root />))
})
app.listen(3000, () => {
console.log("running on port 3000")
})
root.js
const React = require("react");
module.export = class root extends React.Component{
render(){
return(
<div>Hello world from react</div>
)
}
}
package.json:
{
"name": "myproject",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon app.js --exec babel-node --presets es2015,stage-2,react"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.16.2",
"koa": "^2.3.0",
"koa-router": "^7.2.1",
"koa-static": "^4.0.1",
"koa-static-server": "^1.3.2",
"react": "^16.0.0",
"react-dom": "^16.0.0",
"react-dom-server": "0.0.5"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-preset-es2016": "^6.24.1",
"babel-preset-react": "^6.24.1"
}
}
Note: This is an experimental project, so there is a lot of unnecessary packages (koa)
And to make things simple my questions are:
What does express do?(send static html files to the client which then interact on its own? routing?) and how do you send a react component to the client?
my jsx problem above
New Problem (Ryan):
res.send(renderToString(<Root />))
^
SyntaxError: Unexpected token <
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:588:28)
at Object.Module._extensions..js (module.js:635:10)
at Module.load (module.js:545:32)
at tryModuleLoad (module.js:508:12)
at Function.Module._load (module.js:500:3)
at Function.Module.runMain (module.js:665:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3
I updated your code with latest syntax, please give it a try
root.js
const React = require("react");
export default class Root extends React.Component {
render(){
return (
<div>
Hello world from react
</div>
)
}
}
app.js
const express = require("express")
const React = require("react")
const renderToString = require("react-dom/server").renderToString
const Root = require("./public/root").default
const app = express();
app.get("/", (req, res) => {
res.send(renderToString(<Root />))
})
app.listen(3000, () => {
console.log("running on port 3000")
})
package.json
{
"name": "myproject",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon app.js --exec babel-node"
},
"author": "",
"license": "ISC",
"dependencies": {
"ejs": "^2.5.7",
"express": "^4.16.2",
"nodemon": "^1.12.1",
"react": "^16.0.0",
"react-dom": "^16.0.0"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-preset-env": "^1.6.1",
"babel-preset-react": "^6.24.1"
}
}
.babelrc - ADD this file to your project, it's cleaner and easier
{
"presets": [
"react",
["env", {
"targets": {
"browsers": ["last 2 versions", "safari >= 7"]
}
}]
]
}
This setting uses the babel-present-env to prevent the confusion of babel preset settings (like stage-*)
Tested on Node 8