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

.babelrc in a parent directory interferes with npm test #949

Closed
fadeojo opened this issue Oct 24, 2016 · 8 comments
Closed

.babelrc in a parent directory interferes with npm test #949

fadeojo opened this issue Oct 24, 2016 · 8 comments

Comments

@fadeojo
Copy link

fadeojo commented Oct 24, 2016

Description

What are you reporting?
I scaffold a new app and run npm test

Expected behavior

successful test coverage and count

Actual behavior

╰─○ npm test

> nethan@0.1.0 test /Users/fadeojo/Development/react/nethan
> react-scripts test --env=jsdom
 FAIL  src/App.test.js
  ● Test suite failed to run

    Couldn't find preset "es2015" relative to directory "/Users/fadeojo/Development/react"

      at node_modules/react-scripts/node_modules/babel-core/lib/transformation/file/options/option-manager.js:298:19
      at Array.map (native)
      at OptionManager.resolvePresets (node_modules/react-scripts/node_modules/babel-core/lib/transformation/file/options/option-manager.js:269:20)
      at OptionManager.mergePresets (node_modules/react-scripts/node_modules/babel-core/lib/transformation/file/options/option-manager.js:258:10)
      at OptionManager.mergeOptions (node_modules/react-scripts/node_modules/babel-core/lib/transformation/file/options/option-manager.js:243:14)
      at OptionManager.init (node_modules/react-scripts/node_modules/babel-core/lib/transformation/file/options/option-manager.js:373:12)
      at File.initOptions (node_modules/react-scripts/node_modules/babel-core/lib/transformation/file/index.js:221:65)
      at new File (node_modules/react-scripts/node_modules/babel-core/lib/transformation/file/index.js:141:24)
      at Pipeline.transform (node_modules/react-scripts/node_modules/babel-core/lib/transformation/pipeline.js:46:16)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        0.795s
Ran all test suites.

Environment

Run these commands in the project folder and fill in their results:

  1. npm ls react-scripts (if you haven’t ejected): react-scripts@0.7.0
  2. node -v: v6.7.0
  3. npm -v:3.10.3

Then, specify:

  1. Operating system:
    Macbook-pro
  2. Browser and version:

Reproducible Demo

https://github.com/fadeojo/demo

@fadeojo fadeojo changed the title npm test fails for newly generated scaffold app npm test fails for newly generated app Oct 24, 2016
@gaearon
Copy link
Contributor

gaearon commented Oct 24, 2016

Please run:

npm install -g npm@latest

cd your_project_directory
rm -rf node_modules
npm install

and try to reproduce the issue again.

Can you still reproduce it?

@stephencelis
Copy link

I'm also seeing an issue with npm test and a freshly generated project: it hangs indefinitely. (Could it be an issue with watchman not finding any test files?)

Anything I can do to debug? npm is up to date and node_modules directory freshly generated.

@gaearon
Copy link
Contributor

gaearon commented Oct 25, 2016

@stephencelis

This issue is not about hanging, it's about a crash due to a missing preset. Could you please file a new issue with details about your setup and your console output / screenshot?

@stephencelis
Copy link

@gaearon Done! #960

Apologies for moving off topic!

@fadeojo
Copy link
Author

fadeojo commented Oct 31, 2016

@gaearon same result.
Couldn't find preset "es2015" relative to directory "/Users/fadeojo/Development/react" it's loking for the preset one dir up instead of /Users/fadeojo/Development/react/nethan

@gaearon
Copy link
Contributor

gaearon commented Oct 31, 2016

I have a suspicion you might have a stray .babelrc file in one of the above directories.
If you do, delete it.

For example, make sure /Users/fadeojo/Development/react/.babelrc doesn't exist.

@fadeojo
Copy link
Author

fadeojo commented Oct 31, 2016

@gaearon you were right. This issue is resolved.

@fadeojo fadeojo closed this as completed Oct 31, 2016
@gaearon
Copy link
Contributor

gaearon commented Oct 31, 2016

Let's reopen because ideally .babelrc in parent directories should be ignored.

@gaearon gaearon reopened this Oct 31, 2016
@gaearon gaearon changed the title npm test fails for newly generated app .babelrc in a parent directory interferes with npm test Oct 31, 2016
@lock lock bot locked and limited conversation to collaborators Jan 22, 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

3 participants