Skip to content
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

Build fails with @babel/preset-env 7.4.0 #3671

Closed
AegirLeet opened this issue Mar 19, 2019 · 38 comments · Fixed by babel/babel#9711
Closed

Build fails with @babel/preset-env 7.4.0 #3671

AegirLeet opened this issue Mar 19, 2019 · 38 comments · Fixed by babel/babel#9711

Comments

@AegirLeet
Copy link

AegirLeet commented Mar 19, 2019

This has been fixed in @babel/preset-env@7.4.1. You will need to delete yarn.lock/package-lock.json and run yarn/npm i again.

Version

3.5.1

Environment info


Environment Info:

  System:
    OS: Linux 4.18 Debian GNU/Linux 9 (stretch) 9 (stretch)
    CPU: (12) x64 Intel(R) Xeon(R) CPU D-1531 @ 2.20GHz
  Binaries:
    Node: 11.12.0 - /usr/bin/node
    Yarn: 1.15.2 - /usr/bin/yarn
    npm: 6.7.0 - /usr/bin/npm
  Browsers:
    Chrome: Not Found
    Firefox: Not Found
  npmPackages:
    @vue/babel-helper-vue-jsx-merge-props:  1.0.0-beta.2
    @vue/babel-plugin-transform-vue-jsx:  1.0.0-beta.2
    @vue/babel-preset-app:  3.5.1
    @vue/babel-preset-jsx:  1.0.0-beta.2
    @vue/babel-sugar-functional-vue:  1.0.0-beta.2
    @vue/babel-sugar-inject-h:  1.0.0-beta.2
    @vue/babel-sugar-v-model:  1.0.0-beta.2
    @vue/babel-sugar-v-on:  1.0.0-beta.2
    @vue/cli-overlay:  3.5.1
    @vue/cli-plugin-babel: ^3.5.0 => 3.5.1
    @vue/cli-plugin-eslint: ^3.5.0 => 3.5.1
    @vue/cli-service: ^3.5.0 => 3.5.1
    @vue/cli-shared-utils:  3.5.1
    @vue/component-compiler-utils:  2.6.0
    @vue/preload-webpack-plugin:  1.1.0
    @vue/web-component-wrapper:  1.2.0
    eslint-plugin-vue: ^5.0.0 => 5.2.2
    vue: ^2.6.6 => 2.6.9
    vue-eslint-parser:  5.0.0
    vue-hot-reload-api:  2.3.3
    vue-loader:  15.7.0
    vue-style-loader:  4.1.2
    vue-template-compiler: ^2.5.21 => 2.6.9
    vue-template-es2015-compiler:  1.9.1
  npmGlobalPackages:
    @vue/cli: Not Found


Steps to reproduce

yarn global add @vue/cli
vue create -d vue-cli-test
cd vue-cli-test
yarn build

What is expected?

A successful build.

What is actually happening?

The build fails because @babel/preset-env/data/built-ins.json can't be found. It seems this file doesn't exist anymore as of @babel/preset-env 7.4.0.

@AegirLeet
Copy link
Author

Related babel commit: babel/babel@3303b07

@BobNobrain
Copy link

I have the same issue. Full error output looks like

 ERROR  Failed to compile with 1 errors                                                                         01:04:29

 error  in ./src/main.js

Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: [BABEL] /home/bob/git/misc/test/src/main.js: Cannot find module '@babel/preset-env/data/built-ins.json' (While processing: "/home/bob/git/misc/test/node_modules/@vue/babel-preset-app/index.js")
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at getPolyfills (/home/bob/git/misc/test/node_modules/@vue/babel-preset-app/index.js:18:24)
    at module.exports (/home/bob/git/misc/test/node_modules/@vue/babel-preset-app/index.js:105:17)
    at loadDescriptor (/home/bob/git/misc/test/node_modules/@babel/core/lib/config/full.js:165:14)
    at cachedFunction (/home/bob/git/misc/test/node_modules/@babel/core/lib/config/caching.js:33:19)
    at loadPresetDescriptor (/home/bob/git/misc/test/node_modules/@babel/core/lib/config/full.js:235:63)
    at config.presets.reduce (/home/bob/git/misc/test/node_modules/@babel/core/lib/config/full.js:77:21)
    at Array.reduce (<anonymous>)
    at recurseDescriptors (/home/bob/git/misc/test/node_modules/@babel/core/lib/config/full.js:74:38)
    at loadFullConfig (/home/bob/git/misc/test/node_modules/@babel/core/lib/config/full.js:108:6)
    at process.nextTick (/home/bob/git/misc/test/node_modules/@babel/core/lib/transform.js:28:33)
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)

 @ multi (webpack)-dev-server/client?http://192.168.1.182:8080/sockjs-node (webpack)/hot/dev-server.js ./src/main.js

@mikerogne
Copy link

mikerogne commented Mar 19, 2019

This PR was merged 2 hours ago & includes a commit that deleted the built-ins.json file.

PR: babel/babel#7646
Commit: babel/babel@3303b07#diff-0ec74dc48ab9f3209ac7e2816fb79b21

EDIT: Oh sorry, @AegirLeet already mentioned the commit 🤐

@perkola
Copy link

perkola commented Mar 19, 2019

isPluginRequired has moved and the built-ins have changed to corejs2-built-ins.json. The following update resolves the issue:

const { isPluginRequired } = require('@babel/preset-env/lib/filter-items')
const builtInsList = require('@babel/preset-env/data/corejs2-built-ins.json')

Edit: I forgot to specify the file @vue/babel-preset-app/index.js

@ajanssens
Copy link

ajanssens commented Mar 19, 2019

This PR was merged 2 hours ago & includes a commit that deleted the built-ins.json file.

PR: babel/babel#7646
Commit: babel/babel@3303b07#diff-0ec74dc48ab9f3209ac7e2816fb79b21

EDIT: Oh sorry, @AegirLeet already mentioned the commit 🤐

A PR has been open bringing back isPluginRequired but won't fix the built-ins.json issue.
babel/babel#9709
Issue related: babel/babel#9707

@kculmback
Copy link

kculmback commented Mar 19, 2019

In the meantime adding "@babel/preset-env": "7.3.4", to your package.json should do the trick.

@mikerogne
Copy link

In the meantime adding "@babel/preset-env": "7.3.4", to your package.json should do the trick.

Can confirm, does work! :)

@perkola
Copy link

perkola commented Mar 19, 2019

I created a quick PR #3673 but I'm not sure if is is an adequate solution.

@samdjstevens
Copy link

samdjstevens commented Mar 19, 2019

In the meantime adding "@babel/preset-env": "7.3.4", to your package.json should do the trick.

Just done a fresh vue create, added this to the dev depdendencies, but still getting:

isPluginRequired is not a function - any ideas?

@BobNobrain
Copy link

Ok, isPluginRequired was just merged in babel/babel#9709, but built-ins file was not

@nicolo-ribaudo
Copy link

Could anyone try to

  1. Clone the Babel repo
  2. Checkout Alias @babel/preset-env/data/built-ins.json.js babel/babel#9711
  3. Run make bootstrap (it needs yarn)
  4. Symlink packages/babel-preset-env/ in the node_modules of a broken vue project, so that vue-cli will pick it up
  5. Check if that PR fixes the issue?

@AegirLeet
Copy link
Author

@nicolo-ribaudo Yeah, that seems to fix the issue.

nicolo-ribaudo added a commit to babel/babel that referenced this issue Mar 19, 2019
Fixes vuejs/vue-cli#3671

Even if it has the `.js` extension, `require("@babel/preset-env/data/built-ins.json")` will still work.
@stevenroussey-privicy
Copy link

stevenroussey-privicy commented Mar 19, 2019

On the broken repo I added "@babel/preset-env": "^7.3.4", but it did not help.

❯❯❯ yarn why @babel/preset-env                                 master ◼
yarn why v1.13.0
[1/4] 🤔  Why do we have the module "@babel/preset-env"...?
[2/4] 🚚  Initialising dependency graph...
[3/4] 🔍  Finding dependency...
[4/4] 🚡  Calculating file sizes...
=> Found "@babel/preset-env@7.4.0"
info Has been hoisted to "@babel/preset-env"
info Reasons this module exists
   - Specified in "devDependencies"
   - Hoisted from "@vue#cli-plugin-babel#@vue#babel-preset-app#@babel#preset-env"
info Disk size without dependencies: "276KB"
info Disk size with unique dependencies: "9.48MB"
info Disk size with transitive dependencies: "38.4MB"
info Number of shared dependencies: 76
✨  Done in 0.90s.

@nicolo-ribaudo
Copy link

We just released @babel/preset-env@7.4.1, which should fix the issue.

@AegirLeet
Copy link
Author

Can confirm @babel/preset-env@7.4.1 fixes this.

@stevenroussey-privicy
Copy link

No I get the other error:

Module build failed (from ./node_modules/babel-loader/lib/index.js):
TypeError: [BABEL] ./src/main.js: isPluginRequired 
is not a function (While processing: "./node_modules/@vue/babel-preset-app/index.js")

@nicolo-ribaudo
Copy link

What does npx nls why @babel/preset-env say?

@stevenroussey-privicy
Copy link

❯❯❯ npx nls why @babel/preset-env                                                                                                                                                master ◼
npx: installed 8 in 2.742s

  Who required @babel/preset-env:

  project > @babel/preset-env@^7.4.1
  project > @vue/cli-plugin-babel > @vue/babel-preset-app > @babel/preset-env@^7.0.0

@stevenroussey-privicy
Copy link

❯❯❯ yarn why @babel/preset-env                                                                                                                                                   master ◼
yarn why v1.13.0
[1/4] 🤔  Why do we have the module "@babel/preset-env"...?
[2/4] 🚚  Initialising dependency graph...
[3/4] 🔍  Finding dependency...
[4/4] 🚡  Calculating file sizes...
=> Found "@babel/preset-env@7.4.1"
info Has been hoisted to "@babel/preset-env"
info This module exists because it's specified in "devDependencies".
info Disk size without dependencies: "280KB"
info Disk size with unique dependencies: "9.48MB"
info Disk size with transitive dependencies: "38.41MB"
info Number of shared dependencies: 76
=> Found "@vue/babel-preset-app#@babel/preset-env@7.4.0"
info This module exists because "@vue#cli-plugin-babel#@vue#babel-preset-app" depends on it.
info Disk size without dependencies: "276KB"
info Disk size with unique dependencies: "9.48MB"
info Disk size with transitive dependencies: "38.4MB"
info Number of shared dependencies: 76
✨  Done in 1.12s.

@nicolo-ribaudo
Copy link

@vue/babel-preset-app still uses @babel/preset-env@7.4.0 in your node_modules. I suggest deleting node_modules and running yarn again.

@stevenroussey-privicy
Copy link

No change. :/

@nicolo-ribaudo
Copy link

Does yarn why @babel/preset-env print the same thing?

@stevenroussey-privicy
Copy link

Yes

@andreyrd
Copy link

I had to delete yarn.lock. You may be able to find the reference to 7.4.0 in the lockfile as well and remove that manually.

@nicolo-ribaudo
Copy link

@AegirLeet
Could you edit the original issue mentioning that this issue has been fixed in @babel/preset-env@7.4.1 and that people can fix it by deleting yarn.lock/package-lock.json and running yarn/npm i again?

@AegirLeet
Copy link
Author

@nicolo-ribaudo I've added a note at the top.

@nicolo-ribaudo
Copy link

nicolo-ribaudo commented Mar 19, 2019

@stevenroussey-desiclabs Yeah, we had to introduce a deprecation warning to prevent people from accidentally generating imports to core-js@2 with preset-env while having core-js@3 (released today) in their node_modules.
You can ignore it for now, but if anyone wants to open a PR to this repo adding that option to @babel/preset-env and upgrading to ^7.4.1 it would be 🔝 (cc @perkola since you wrote the original PR).

@dustinmichels
Copy link

Should @babel/core@^7.0.0 also be added? If I just add @babel/preset-env@7.4.1 to devDependencies I get a lot of has unmet peer dependency "@babel/core@^7.0.0-0". warnings.

@nicolo-ribaudo
Copy link

You don't need to add @babel/preset-env@7.4.1 to your devDeps, you just need to delete node_modules/lockfile and re-run yarn or npm i

@perkola
Copy link

perkola commented Mar 19, 2019

@nicolo-ribaudo I created a new PR with the correct built-ins path and a dependency bump to 7.4.1, see #3674.

Edit: I'm not sure why the build is failing on my PR. I have no more time on hand so if anyone wants to continue, feel free.

@stevenroussey-privicy
Copy link

@sroussey
Copy link

@nicolo-ribaudo
Copy link

nicolo-ribaudo commented Mar 19, 2019

2 is fine (I don't know this project well enough to say if updating to 3 would be a breaking change). You need to copy that line to envOptions.

@LiuJi-Jim
Copy link

LiuJi-Jim commented Mar 20, 2019

OK, I am working again. :)

One thing I noticed was:

With `useBuiltIns` option, required direct setting of `corejs` option

I do think you did something right.
I changed useBuiltIns to false and manually import "@babel/polyfill" and it finally works.
I think something's going wrong with useBuiltIns: 'usage'. It's trying to resolve the code and import core-js one-by-one. But things go wrong with @babel/preset-env@7.4.1 when working with core-js@3.0.0, it resolves dependencies incorrectly, which gives us some Module not found errors.

@nicolo-ribaudo
Copy link

If you are using core-js@3, you need to pass the corejs: 3 option to the preset-env package. By default it uses core-js@2, like it did in previous releases (but now it warms if you don't set corejs: 2).

kkoji pushed a commit to kkoji/vue.js-lecture that referenced this issue Mar 25, 2019
@markg85
Copy link

markg85 commented Mar 30, 2019

Hi,

I just ran into this very same issue.

I have the 3.5.3 cli.

According to the release notes that version fixes these issues. Not so much in my experience :(

Now, despite a range of solutions that have been posted here, I actually have no clue how i can fix this.. I have installed the cli with:
npm i -g @vue/cli

As per most guides on how to use vue (have it installed globally). So what should i change now - and where? - to get this working?

Thank you :)

@haoqunjiang
Copy link
Member

@markg85

  1. make sure the local @vue/cli-plugin-babel dependency in your project is the latest version
  2. if that doesn't help, try to run npm install --save core-js@2 in the project root.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.