-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
babel-cli and babel-node ignore global presets (installed with npm -g) #2816
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
Comments
Installing Babel globally should be avoided. If you need Babel in a project, you should install it into the project itself and run it as an npm script or via
or
|
from the docs (https://babeljs.io/docs/usage/cli/): Using npm you can install Babel globally, making it available from the command line. so: globally or not? |
I agree that in general it should be avoided and I personally install babel as dev dependency in my projects, but I like using the CLI for quick tests. For example, how am I supposed to try all these new cool presets? 😄 |
Why wouldn't you be able to use the CLI just because you installed it with |
I am well aware of the workarounds you listed, I reported the issue because it's inconsistent with the documentation and I'm not completely sure if this should be considered a bug or not. |
We resolve plugins and presets relative to the input file path. You're using the CLI and haven't referenced a file on disk so there's nowhere for it to be resolved from. Put it in a file and execute it and it will work. |
I'd love to be able to fire up a REPL for some quick tests written in ES6. Sometimes you just want to test something out and there's no project context to do it in. Couldn't babel-node resolve the path for presets based on the current working directory with a fallback to global node-modules if no input file was specified? Maybe I'm totally missing something, but it seems pointless to have a babel based REPL if you can't load any presets or plugins. |
The REPL was already came with a lot of caveats, I'm tempted to say remove it. |
I'm also using
And then run your test
Obviously it would be ideal if |
@kittens As I can see this is not exactly how it works now. When I run babel-node in server directory and pass it server.js as a input file it raises an error because it can't find react preset relative to directory \client\components. I have react preset installed in server/node_modules but not in client/node_modules. |
Here are the steps to reproduce the problem:
The text was updated successfully, but these errors were encountered: