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

Error after upgrading to babel 7 #8835

Open
timotew opened this Issue Oct 10, 2018 · 6 comments

Comments

Projects
None yet
5 participants
@timotew

timotew commented Oct 10, 2018

Bug Report

Current Behavior
A clear and concise description of the behavior.
After upgarding from bable 6 to 7, My dev script stop working and doesn't recorgnize ES6.
I'm using babel-node here is my www file content:
Input Code

  • REPL or Repo link if applicable:
const  { config } = require('dotenv');
config();
import 'babel-polyfill';
var app = require('../app');
var debug = require('debug')('tlikes:server');
var http = require('http');
var socket= require('../socket');

var port = normalizePort(process.env.PORT || '3000');
app.set('port', port);

Expected behavior/code
A clear and concise description of what you expected to happen (or code).
Compile and let nodemon start dev server
Babel Configuration (.babelrc, package.json, cli command)

{
    "presets": ["@babel/preset-env", "@babel/react", "minify"],
    "env": {
        "production": {
          "presets": ["minify"]
        }
      },
    "plugins": ["@babel/plugin-transform-runtime"],
    "exclude": "/node_modules/",
    "ignore": [
            "src/public"
                ]
  }

Environment

  • Babel version(s): ^7.0.0
  • Node/npm version: v10.9.0 / npm 6.2.0
  • OS: OSX 10.13.6
  • Monorepo [no
  • How you are using Babel: cli

Possible Solution

Reverting to babel 6
Additional context/Screenshots
Add any other context about the problem here. If applicable, add screenshots to help explain.
This is my script file:

  "scripts": {
    "start": "nodemon -- src/bin/www --inspect --exec babel-node",
    "build": "BABEL_ENV=production babel src --plugins transform-remove-console --out-dir dist --copy-files &&  babel src/bin/www  --out-file dist/bin/www",
    "serve": "node dist/bin/www",
    "clean": "rm -rf dist",
    "lint": "eslint ./",
    "test": "make test"
  }

Here is my console log

import 'babel-polyfill';
       ^^^^^^^^^^^^^^^^

SyntaxError: Unexpected string
    at new Script (vm.js:73:7)
    at createScript (vm.js:245:10)
    at Object.runInThisContext (vm.js:297: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 startup (internal/bootstrap/node.js:266:19)
[nodemon] app crashed - waiting for file changes before starting...
@babel-bot

This comment has been minimized.

Show comment
Hide comment
@babel-bot

babel-bot Oct 10, 2018

Collaborator

Hey @timotew! 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
community that typically always has someone willing to help. You can sign-up here
for an invite.

Collaborator

babel-bot commented Oct 10, 2018

Hey @timotew! 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
community that typically always has someone willing to help. You can sign-up here
for an invite.

@skwon-mdsol

This comment has been minimized.

Show comment
Hide comment
@skwon-mdsol

skwon-mdsol Oct 11, 2018

you can't just do require('babel-polyfill') ?

skwon-mdsol commented Oct 11, 2018

you can't just do require('babel-polyfill') ?

@cattermo

This comment has been minimized.

Show comment
Hide comment
@cattermo

cattermo Oct 12, 2018

Babel-polyfill is removed since babel 7, use core-js instead.

cattermo commented Oct 12, 2018

Babel-polyfill is removed since babel 7, use core-js instead.

@timotew

This comment has been minimized.

Show comment
Hide comment
@timotew

timotew Oct 12, 2018

@skwon-mdsol That the purpose of using babel in the first place.

@cattermo I have removed the babel-polyfill, The error occurs anytime I use ES6 import.

import app from '../app';
       ^^^

SyntaxError: Unexpected identifier
    at new Script (vm.js:73:7)
    at createScript (vm.js:245:10)
    at Object.runInThisContext (vm.js:297: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 startup (internal/bootstrap/node.js:266:19)

timotew commented Oct 12, 2018

@skwon-mdsol That the purpose of using babel in the first place.

@cattermo I have removed the babel-polyfill, The error occurs anytime I use ES6 import.

import app from '../app';
       ^^^

SyntaxError: Unexpected identifier
    at new Script (vm.js:73:7)
    at createScript (vm.js:245:10)
    at Object.runInThisContext (vm.js:297: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 startup (internal/bootstrap/node.js:266:19)
@skwon-mdsol

This comment has been minimized.

Show comment
Hide comment
@skwon-mdsol

skwon-mdsol Oct 12, 2018

@cattermo https://babeljs.io/docs/en/babel-polyfill polyfill still exists, it's just named differently - using the submodule prefix

skwon-mdsol commented Oct 12, 2018

@cattermo https://babeljs.io/docs/en/babel-polyfill polyfill still exists, it's just named differently - using the submodule prefix

@bertho-zero

This comment has been minimized.

Show comment
Hide comment
@bertho-zero

bertho-zero Oct 15, 2018

I have the same problem in a monorepo since I did a babel.config.js at root and I have no .babelrc.js in my package.

EDIT: It's works fine for me with a .babelrc that contains

{
  "extends": "../../.babelrc.js"
}

bertho-zero commented Oct 15, 2018

I have the same problem in a monorepo since I did a babel.config.js at root and I have no .babelrc.js in my package.

EDIT: It's works fine for me with a .babelrc that contains

{
  "extends": "../../.babelrc.js"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment