Skip to content
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

BABEL FAILING WHILE USING NPM BUILD #8944

Closed
cjmacharia opened this issue Oct 30, 2018 · 7 comments
Closed

BABEL FAILING WHILE USING NPM BUILD #8944

cjmacharia opened this issue Oct 30, 2018 · 7 comments
Labels
i: question outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@cjmacharia
Copy link

cjmacharia commented Oct 30, 2018

Bug Report

Current Behaviour
When i run npm run build where the build command is
babel -d ./build . -s
I get a SyntaxError:

node_modules/@babel/helper-plugin-utils/src/index.js: Unexpected token, expected , (93:5)
  91 |       version,
  92 |       range,
  93 |     }: any),
     |      ^
  94 |   );
  95 | }

my babel dependancies

                "@babel/preset-es2015": "^7.0.0-beta.53",
		"@babel/preset-es2017": "^7.0.0-beta.53",
		"babel-core": "^6.26.3",
		"babel-istanbul": "^0.12.2",
		"babel-loader": "^8.0.4",
		"babel-plugin-transform-runtime": "^6.23.0",
		"babel-polyfill": "^6.26.0",
		"babel-preset-es2015": "^6.24.1",
		"babel-preset-stage-0": "^6.24.1",
		"babel-register": "^6.26.0", `

my .babelrc file

{
	"presets": [
		"es2015",
		"stage-3"
	],
	"plugins": [],
	"env": {
		"test": {
			"plugins": [
				"istanbul"
			]
		}
	}
}

my package.json file

     "build-babel": "babel -d ./build . -s",
     "clean": "rm -rf build && mkdir build",
    "build": "npm run clean && npm run build-babel ",

Environment

  • Node/npm version: [ Node v8.11.3/npm 6.4.0]

  • OS: OSX 10.13.4

Possible Solution

Additional context/Screenshots
Add any other context about the problem here. If applicable, add screenshots to help explain.
when i navigate to the index file , I get this

screen shot 2018-10-30 at 11 49 51

if I place replace the colon with a comma, the build passes this stage but then fails with

Couldn't find preset "env" relative to directory "/Users/collinsmacharia/Documents/javascript/angular-4/moviefy/node_modules/babel-plugin-transform-regenerator/node_modules/regenerator-transform"
    at /Users/collinsmacharia/Documents/javascript/angular-4/moviefy/node_modules/babel-core/lib/transformation/file/options/option-manager.js:293:19
    at Array.map (<anonymous>)
    at OptionManager.resolvePresets (/Users/collinsmacharia/Documents/javascript/angular-4/moviefy/node_modules/babel-core/lib/transformation/file/options/option-manager.js:275:20)
    at OptionManager.mergePresets (/Users/collinsmacharia/Documents/javascript/angular-4/moviefy/node_modules/babel-core/lib/transformation/file/options/option-manager.js:264:10)
    at OptionManager.mergeOptions (/Users/collinsmacharia/Documents/javascript/angular-4/moviefy/node_modules/babel-core/lib/transformation/file/options/option-manager.js:249:14)
    at OptionManager.init (/Users/collinsmacharia/Documents/javascript/angular-4/moviefy/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12)
    at File.initOptions (/Users/collinsmacharia/Documents/javascript/angular-4/moviefy/node_modules/babel-core/lib/transformation/file/index.js:212:65)
    at new File (/Users/collinsmacharia/Documents/javascript/angular-4/moviefy/node_modules/babel-core/lib/transformation/file/index.js:135:24)
    at Pipeline.transform (/Users/collinsmacharia/Documents/javascript/angular-4/moviefy/node_modules/babel-core/lib/transformation/pipeline.js:46:16)
    at transform (/Users/collinsmacharia/Documents/javascript/angular-4/moviefy/node_modules/babel-cli/lib/babel/util.js:50:22)

I would appreciate any sort of help

@babel-bot
Copy link
Collaborator

Hey @cjmash! 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.

@nicolo-ribaudo
Copy link
Member

nicolo-ribaudo commented Oct 30, 2018

For some reason Babel is tranpiling your node_modules. Can you try to exclude it from your config? babel -d ./build . -s --ignore "node_modules/**/*.js"

Also, you are mixing Babel 6 and 7; you should choose either one or the other.

@nateshmbhat
Copy link

I had this problem because of older babel version which I fixed using a stackoverflow answer :
Check this stackoverflow answer : https://stackoverflow.com/a/53927430/6665568

@rootedsoftware
Copy link

I'm getting the same error. When I use the ignore of the node_modules it does work. On windows I used this line in my package.json

    "build-server": "babel -d ./build --ignore node_modules/**/*.js . -s",

@rootedsoftware
Copy link

Scratch that, it still isn't building everything. I only get a partial set of my node_modules in the build folder.

@rootedsoftware
Copy link

Moving my files into a ./src directory and then changing my build to pull from that folder fixed this problem for me.

"babel ./src -d ./build -s"

@ghost
Copy link

ghost commented Mar 4, 2019

I had this same problem too but ignoring my node_modules helped me fix this, thanks @nicolo-ribaudo

@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Aug 16, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Aug 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
i: question outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

No branches or pull requests

5 participants