Couldn't find preset "env" relative to directory

skwny picture skwny · Feb 18, 2018 · Viewed 27.4k times · Source

So far I have been unsuccessful in an attempt to use the env preset. I browsed the git issues that others have raised such as this, and implemented some of the suggestions that appeared to work for others, but no luck so far.

Here's what I'm working with:

package.json

"bundle": "browserify ./client/app.js -d -o ./public/o.js -t [ babelify --presets [ env ] ]",
"devDependencies": {
  "@babel/cli": "^7.0.0-beta.40",
  "@babel/preset-env": "^7.0.0-beta.40",
  "babel-core": "^6.26.0",
  "babelify": "^8.0.0"
...

And here is the error:

Error: Couldn't find preset "env" relative to directory "/Users/user/Documents/git/ts/client" while parsing file: /Users/user/Documents/git/ts/client/app.js

Anything I could be missing?

Answer

Phil picture Phil · Feb 23, 2018

Many of the github issues relating to this suggest that babel-preset-env is not installed.

Indeed it doesn't seem to be there in your package.json. Add & install it by doing this:

npm install babel-preset-env --save