question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Babel rootMode:"upward" issue

See original GitHub issue

I’ve recently attempted an upgrade of a decently sized monorepo I’ve successfully managed with Nx so far. I followed the usual procedure in going from 9.2.3 to latest, and no apparent issues or warnings came up along the process.

Current Behavior

When I try to start or build any of the apps that are in the repo (or a newly created one, for what is worth) I always get the same issue:

ERROR in ./main.tsx
Module build failed (from /Users/alf/monorepopath/node_modules/babel-loader/lib/index.js):
Error: Babel was run with rootMode:"upward" but a root could not be found when searching upward from "/Users/alf/monorepopath/apps/testapp/src"

And I get a reference to the same error in relation to ./polyfills.ts as well.

NOTE: Jest tests are running fine, Storybook instances for all libs in the same repo are building just fine too.

Expected Behavior

The app to run and build properly as it does on the same machine if I create a Nx Workspace from scratch.

Steps to Reproduce

Not sure how to reproduce, since it seems related to my existing setup. I am not entirely sure that qualifies as a “bug”, but I am posting here to see if anyone has similar issues or one of the Nx gurus can point me in the right direction for a fix…

Here’s what I’ve tried so far:

  • remove node_modules and yarn.lock and go for a fresh install -> same outcome
  • checked out the repo and tried the same on a different machine with different OS (Win 10) -> same outcome
  • went through a side-by-side comparison between the ‘upgraded’ workspace and the newly created one, at least the package dependencies and workspace configuration, and couldn’t spot anything weird or unexpected.

Environment

MacOS 10.15.5 with Node 12.17.0

  @nrwl/angular : Not Found
  @nrwl/cli : 9.4.2
  @nrwl/cypress : 9.4.2
  @nrwl/eslint-plugin-nx : 9.4.2
  @nrwl/express : Not Found
  @nrwl/jest : 9.4.2
  @nrwl/linter : 9.4.2
  @nrwl/nest : Not Found
  @nrwl/next : Not Found
  @nrwl/node : Not Found
  @nrwl/react : 9.4.2
  @nrwl/schematics : Not Found
  @nrwl/tao : 9.4.2
  @nrwl/web : 9.4.2
  @nrwl/workspace : 9.4.2
  typescript : 3.9.5

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:5
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
kraizcommented, Aug 17, 2020

Same issue, upgraded from 8.2 to 10.0. There was no babel.config.json created via migration. Did not find a migration that actually did it. Created it by hand (like @paustint’s one), works fine now.

{
  "presets": ["@nrwl/web/babel"],
  "babelrcRoots": ["*"]
}
1reaction
jaysoocommented, Jul 24, 2020

@alfonsobravi it looks like some of the babel versions are mismatched. At this point you wouldn’t need to install babel presets like env, react, typescript, since the Nx presets have them as dependencies.

Can folks try removing @babel/* packages from their dependencies and see if that helps? If you have any custom plugins that you’re relying on you can still keep them.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Options - Babel.js
"root" is the default mode because it avoids the risk that Babel will accidentally load a babel.config.json that is entirely outside of the...
Read more >
babeljs - Babel: root programmatic options - Stack Overflow
Your answer tells me they are. If you're using the Babel CLI directly, pass --root-mode upward as documented here. Took me a while...
Read more >
babel-loader - webpack
This package allows transpiling JavaScript files using Babel and webpack. Note: Issues with the output should be reported on the Babel Issues tracker....
Read more >
Vue.config.js set babel's `rootMode` option - Get Help
I can't figure out how to configure babel to use the rootMode of "upward" so that it looks for the babel config in...
Read more >
babel-plugin-transform-default-named-imports - npm package
When monorepo is set to true , upward root mode is used. This looks for the closest node_modules directory within any ancestor directory...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found