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

root-mode for babel-node #9137

Closed
theprobugmaker opened this issue Dec 7, 2018 · 7 comments · Fixed by #9148
Closed

root-mode for babel-node #9137

theprobugmaker opened this issue Dec 7, 2018 · 7 comments · Fixed by #9148
Labels
Has PR i: bug outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@theprobugmaker
Copy link

I'm using Babel 7 and I have a monorepo with lerna and yarn workspaces, I could configure the script like this: babel src --root-mode upward --out-dir dist --delete-dir-on-start and it works really nice, however I want to use nodemon with babel-node but I noticed that I can't specify --root-mode for babel-node, what can I do to solve that?

nodemon --legacy-watch --exec babel-node -- src/index

@nicolo-ribaudo
Copy link
Member

It should work in @babel/node 7.2.0 (#9078)

@theprobugmaker
Copy link
Author

I'm using 7.2.0 but still not working.
babel-node --root-mode upward src/index.js

internal/modules/cjs/loader.js:605
throw err;
^

Error: Cannot find module 'C:\Users\ZD\Desktop\acme\packages\server\upward'

@nicolo-ribaudo
Copy link
Member

What does npx nls why @babel/cli say? Maybe for some reason it is loading an older version.

@theprobugmaker
Copy link
Author

Who required @babel/cli:
acme > @babel/cli@^7.2.0

When I run babel-node -- src/index.js --root-mode upward making --root-mode the last param it runs the command but it doesn't seem to load the config, it throws me an error:

(function (exports, require, module, __filename, __dirname) { import express from 'express'
SyntaxError: Unexpected identifier

It's only working for build using babel src --root-mode upward --out-dir dist

@theprobugmaker
Copy link
Author

theprobugmaker commented Dec 7, 2018

That is how my babel.config.js looks like:

module.exports = (api) => {
  api.cache(true)
	
  return {
    presets: [
      [
        "@babel/env",
        {
          targets: {
            node: true
          }
        }
      ]
    ],
    ignore: ['node_modules']
  }
}

@loganfsmyth
Copy link
Member

Can you try

babel-node --root-mode upward src/index.js 

@theprobugmaker
Copy link
Author

@loganfsmyth

yarn babel-node --root-mode upward src/index.js

internal/modules/cjs/loader.js:605
throw err;
Error: Cannot find module 'C:\Users\ZD\Desktop\acme\packages\server\upward'

It's trying to load upward as a module

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

Successfully merging a pull request may close this issue.

3 participants