-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Labels
outdatedA closed issue/PR that is archived due to age. Recommended to make a new issueA closed issue/PR that is archived due to age. Recommended to make a new issue
Description
Here are the steps to reproduce the problem:
$ babel --version
6.1.1 (babel-core 6.0.20)
$ npm ls -g --depth=0 | grep babel-preset
βββ babel-preset-es2015@6.0.15
$ babel --presets es2015 index.js
Error: Couldn't find preset "es2015"
at OptionManager.mergePresets (/Users/user/.node/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/options/option-manager.js:310:17)
(...)
$ babel-node --version
6.1.1
$ babel-node --presets es2015 -e "const foo = 'bar'"
Error: Couldn't find preset "es2015"
at OptionManager.mergePresets (/Users/user/.node/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/options/option-manager.js:310:17)
(...)
Metadata
Metadata
Assignees
Labels
outdatedA closed issue/PR that is archived due to age. Recommended to make a new issueA closed issue/PR that is archived due to age. Recommended to make a new issue
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
loganfsmyth commentedon Nov 4, 2015
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
RobertCZ commentedon Nov 4, 2015
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?
moretti commentedon Nov 4, 2015
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? π
GGAlanSmithee commentedon Nov 4, 2015
Why wouldn't you be able to use the CLI just because you installed it with
--save
or--save-dev
? It's still installed, just not globally accessable. It's in thenode_modules/.bin
folder.. Or am I missunderstanding something?moretti commentedon Nov 4, 2015
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.
sebmck commentedon Nov 4, 2015
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.
Bargs commentedon Nov 10, 2015
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.
jamiebuilds commentedon Nov 11, 2015
The REPL was already came with a lot of caveats, I'm tempted to say remove it.
bradfloodx commentedon Aug 9, 2017
I'm also using
babel-cli
andbabel-node
for running quick tests locally without having a whole project set up. You can easily install the preset in the folder you are testing:And then run your test
Obviously it would be ideal if
babel-node
checked the global folder after checking the current working directory, but this is a workaround that is fairly easy to do.RoboBurned commentedon Oct 3, 2017
@kittens As I can see this is not exactly how it works now.
I have the following file structure.
server
server.js
import App from '..\client\components\App'
client
components
App.jsx
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.
So if I understood correct it looks for presets for each file it process.