Reputation: 3241
Just cli suddently has stopped working, all test fail with:
Cannot find module 'babel-preset-env' from '/PATH'
- Did you mean "@babel/env"?
I'm sure it is some kind of incompatibility between a module which uses babel 6 and my project with babel 7, but I'm not sure how can I solve.
This is package.json
{
"name": "testing101",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "parcel index.html",
"test": "jest src/*.js --watchAll",
"nyc": "nyc ava",
"build": "babel src/*.js -d dist"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@babel/core": "^7.4.5",
"@babel/preset-env": "^7.4.5",
"@types/jest": "^24.0.13",
"jest": "^24.8.0",
"nyc": "^14.1.1",
"parcel-bundler": "^1.7.0"
},
"jest": {
"verbose": true,
"testURL": "http://localhost:1234/",
"collectCoverage": true
},
"dependencies": {
"axios": "^0.18.0",
"nock": "^10.0.6"
}
}
This is .babelrc
{
"presets": ["@babel/preset-env"],
"env": {
"test": {
"presets": ["env"]
}
}
}
Upvotes: 31
Views: 68316
Reputation: 11
i had the same error.. The Eslint was going crazy, this worked for me :
{
"extends": ["@sanity/eslint-config-studio", "@babel/core"],
"parser": "@babel/eslint-parser",
"parserOptions": {
"requireConfigFile": false,
"babelOptions": {
"presets": ["@babel/preset-env"]
}
}
}
Upvotes: 1
Reputation: 22461
In the test section of the .babelrc file you have accidentally used an unscoped preset ("presets": ["env"]
). This used to be the way to do it before Babel 7 and the @babel
scope. More than that, since you are already configuring @babel/preset-env
as a global preset, you don't need to define it again for the test environment. Removing the entire test environment configuration as below should fix your problem:
{
"presets": ["@babel/preset-env"]
}
Upvotes: 48
Reputation: 31
I was having the same issue with ReactJS project built using Sanity.
I added the below code to .eslintrc
{
"extends": ["@sanity/eslint-config-studio", "@babel/core"]
}
Upvotes: 2
Reputation: 822
This worked for me:
.babelrc
{
"presets": ["@babel/preset-env"]
}
.eslintrc
(add @babel/core
to the existing list of configs)
{
"extends": ["@babel/core", ...EXISTING-CONFIGS-HERE]
}
Upvotes: 8
Reputation: 21549
I met this problem when I opened 2 terminal with 2 different versions of node. ( I installed NVM to use different versions of nodes )
so the solution is quite simple:
node_modules
npm install
and npm run dev
with the same node version.Upvotes: 2