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

"npm start" error if there is a .babelrc file in parent folder #233

Closed
forclan opened this issue Jul 27, 2016 · 9 comments
Closed

"npm start" error if there is a .babelrc file in parent folder #233

forclan opened this issue Jul 27, 2016 · 9 comments

Comments

@forclan
Copy link

forclan commented Jul 27, 2016

if I have a folder named "React" or some other name.
run create-react-app test-react in folder React
cd ./test-react
run npm start it works fine;

but if I put a .babelrc file in folder "React"
echo "{presets: ['es2015']}" > ../.babelrc
and run npm start
if will cause a error:
Failed to compile. Error in ./src/index.js Module build failed: Error: Couldn't find preset "es2015" relative to directory "/Users/forclan/Documents/Javascript/React" at Array.map (native) @ multi main

It seems that react-scripts will find a .babelrc file the way up to "~"(if i put the .babelrc file in my home folder,it will generate the same error);

@mxstbr
Copy link
Contributor

mxstbr commented Jul 27, 2016

This is a babel-specific feature, see here: https://babeljs.io/docs/usage/babelrc#lookup-behavior

We could add a babel key to the package.json, but I don't think that's worth it. It'll just confuse beginners, and only people who know what they're doing will add a .babelrc to their folder anyway.

Thanks for kicking off this discussion!

@mxstbr mxstbr closed this as completed Jul 27, 2016
@insin
Copy link
Contributor

insin commented Jul 27, 2016

Would adding babelrc: false to the query config for babel-loader prevent this?

Babel itself has a babelrc option which you can set to false to disable config lookup.

@gaearon gaearon reopened this Jul 27, 2016
@gaearon
Copy link
Contributor

gaearon commented Jul 27, 2016

Would adding babelrc: false to the query config for babel-loader prevent this?

I think it should.

@alexzherdev
Copy link
Contributor

Sounds straightforward, is this up for grabs? This needs to happen in both dev and prod, right?

@mxstbr
Copy link
Contributor

mxstbr commented Jul 27, 2016

Would adding babelrc: false to the query config for babel-loader prevent this?

Ohh, nice one @insin!

Feel free to submit a PR @alexzherdev!

@mxstbr
Copy link
Contributor

mxstbr commented Jul 27, 2016

Done by the amazing @alexzherdev in #236! 👍

@mxstbr mxstbr closed this as completed Jul 27, 2016
@hzoo
Copy link

hzoo commented Jul 27, 2016

Anyone want to add a note about using babelrc: false in the docs https://github.com/babel/babel.github.io/blob/master/docs/usage/babelrc.md? Otherwise I'l do it

@loganfsmyth
Copy link

babelrc: false should do the trick for webpack. An alternative would be to add a no-op {} .babelrc file, or put "babel": {} in the package.json so it'll find the local config and stop searching in parents.

@gaearon
Copy link
Contributor

gaearon commented Jul 27, 2016

Can you verify 0.2.0 alpha fixes this? #190

louischan-oursky pushed a commit to louischan-oursky/create-react-app that referenced this issue Jan 25, 2018
Remove tslint-loader from prod build (again)
@lock lock bot locked and limited conversation to collaborators Jan 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants