New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected identifier with babel-node in windows only #9301

vanZeben opened this Issue Jan 8, 2019 · 1 comment


None yet
2 participants
Copy link

vanZeben commented Jan 8, 2019

Bug Report

Current Behavior
In Windows 10, when running a babel-node from a package.json file, babel-node reports gives the following error, note that this works as intended with the same source in OS X and some other Windows instances

(function (exports, require, module, __filename, __dirname) { import app from "../app";
SyntaxError: Unexpected identifier
   at new Script (vm.js:79:7)
   at createScript (vm.js:251:10)
   at Object.runInThisContext (vm.js:303:10)
   at Module._compile (internal/modules/cjs/loader.js:657:28)
   at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
   at Module.load (internal/modules/cjs/loader.js:599:32)
   at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
   at Function.Module._load (internal/modules/cjs/loader.js:530:3)
   at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
   at Object.<anonymous> (C:\Users\Ken\gv6\typecast\node_modules\@babel\node\lib\_babel-node.js:234:23)

This only happens when running babel-node through the package.json file and hitting node_modules/.bin/babel-node in a cmd-prompt works as expected.

This is only happening in some windows instances and OS X is fine.

Input Code

    "name": "typecast",
    "version": "0.0.0",
    "private": true,
    "scripts": {
        "start": "babel-node ./src/server/entry.ts --extensions '.ts'",
        "build:server": "babel src -d dist --extensions \".ts\"",
    "dependencies": {
        "@babel/cli": "^7.2.3",
        "@babel/core": "^7.2.2",
        "@babel/node": "^7.2.2",
        "@babel/plugin-proposal-class-properties": "^7.2.3",
        "@babel/plugin-proposal-json-strings": "^7.2.0",
        "@babel/plugin-syntax-dynamic-import": "^7.2.0",
        "@babel/plugin-syntax-import-meta": "^7.2.0",
        "@babel/plugin-transform-object-assign": "^7.2.0",
        "@babel/plugin-transform-template-literals": "^7.2.0",
        "@babel/polyfill": "^7.2.5",
        "@babel/preset-env": "^7.2.3",
        "@babel/preset-react": "^7.0.0",
        "@babel/preset-typescript": "^7.1.0",
    "devDependencies": {
        "tslint": "^5.11.0",
        "tslint-config-prettier": "^1.14.0",
        "typescript": "^3.2.1",


import app from "../app";

app.set("port", config.EnvConfig.port || 3000);

Expected behavior/code
I am expecting babel-node to process the typescript file properly. Also note that building out the typescript files with babel src -d dist --extensions \".ts\" works as intended.

Babel Configuration (.babelrc, package.json, cli command)
.babelrc at root of the project

    "presets": [
        ["@babel/preset-env", {
            "targets": {
                "browsers": [">0.2%"]
            "modules": "commonjs",
            "useBuiltIns": "usage"
        }], "@babel/preset-react", "@babel/preset-typescript"
    "ignore": ["node_modules"],
    "plugins": ["@babel/plugin-syntax-dynamic-import", "@babel/plugin-syntax-import-meta", "@babel/plugin-proposal-class-properties", "@babel/plugin-proposal-json-strings", "@babel/plugin-transform-template-literals"]


  • Babel version(s): v7.2.2
  • Node/npm version: Node v10.15.0/NPM v6.4.1
  • OS: Windows 10
  • Monorepo: no
  • How you are using Babel: cli & loader

Possible Solution
My suspicion is that the .babelrc file is not being loaded or its being processed as a different directory, however I attempted to specify an absolute path with the --config-file option to no avail


This comment has been minimized.

Copy link

babel-bot commented Jan 8, 2019

Hey @vanZeben! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
that typically always has someone willing to help. You can sign-up here
for an invite.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment