I'm developing a CLI with NodeJS. I use Nodemon for development. So when I do npm run start
(= nodemon --exec babel-node bin/main.js
), everything works fine. However, when I install my CLI (with npm i -g .
) and run it (with opews
(name of my CLI)), I get this error:
Error: Requires Babel "^7.0.0-0", but was loaded with "6.26.3". If you are sure you have a compatible version of @babel/core, it is likely that something in your build process is loading the wrong version. Inspect the stack trace of this error to look for the first entry that doesn't mention "@babel/core" or "babel-core" to see what is calling Babel. (While processing preset: "/Users/arthurfontaine/Documents/Lab/opews/parser/node_modules/@babel/preset-env/lib/index.js")
Here's part of my package.json
:
"dependencies": {
"chalk": "^4.1.0",
"dom-parser": "^0.1.6",
"franc": "^5.0.0",
"jsdom": "^16.2.2",
"lda": "^0.2.0",
"minimist": "^1.2.5",
"node-fetch": "^2.6.0",
"node-vibrant": "^3.1.5"
},
"devDependencies": {
"@babel/cli": "^7.10.5",
"@babel/core": "^7.10.5",
"@babel/node": "^7.10.5",
"@babel/preset-env": "^7.10.4",
"nodemon": "^2.0.4"
},
"scripts": {
"start": "nodemon --exec babel-node bin/main.js"
}
and my .babelrc
:
{
"presets": [
"@babel/preset-env"
]
}
and the header of my main.js
:
#!/usr/bin/env babel-node
'use strict';
What I tried:
- globally uninstall
@babel/cli
to see if it didn't load the globally installed one instead of the project one - uninstall / reinstall "Babel-related" modules in my project with
npm i @babel/cli @babel/node @babel/core @babel/preset-env --save-dev
- install
babel-core@7.0.0-bridge.0
like it says here - install
babel-core
but it install the6.23.3
version
Every time I try, it gives me the same error
What I checked:
- if
6.23.3
appears in mypackage-lock.json
but not - run
npx npm-why @babel/helpers
as it says at this issue. it returns me:
Who required @babel/helpers:
opews > @babel/core > @babel/helpers@7.10.4