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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't resolve core-js/modules/es7.symbol.async-iterator #129

Closed
andylacko opened this issue Jan 27, 2019 · 27 comments
Closed

Can't resolve core-js/modules/es7.symbol.async-iterator #129

andylacko opened this issue Jan 27, 2019 · 27 comments

Comments

@andylacko
Copy link

Hello, I have seen that subpaths were merged, nice 馃憣 Although I see error :/

Can't resolve 'core-js/modules/es7.symbol.async-iterator' in '/Users/andy/Workspace/js/medialer/node_modules/next-i18next/dist/utils'

I am on node v11.8.0, it happened after I updated to v0.23.0

@andylacko
Copy link
Author

forgot to install peer dependency i18next...

@isaachinman
Copy link
Contributor

Hi @andylacko, do you mean that you have to do something more than just yarn add next-i18next? Shouldn't peer deps install automatically?

@andylacko
Copy link
Author

I removed packages, then reinstalled and npm wrote few WARNs, and one of them was that I have to install i18next manually, installed and it was working, dunno, if something is with my package.json or it is mistake in dep config in this lib.

If you want to check just reinstall packages and see if if it is specific to my setup, or not

@lucasfeliciano
Copy link
Contributor

lucasfeliciano commented Jan 28, 2019

Got the same here today when installed the last version of next-i18next
Even after manually installing i18next I didn't manage to get it working
Can we reopen this issue until we figure out the dependencies conflicts?

@isaachinman
Copy link
Contributor

So, I believe the es7.symbol.async-iterator thing is from Babel.

@capellini Are you sure this is related to v0.23.0? What version are you upgrading from? Let's try to narrow the problem down to a specific release.

@isaachinman isaachinman reopened this Jan 28, 2019
@isaachinman
Copy link
Contributor

Could be related to 9c96479.

@lucasfeliciano
Copy link
Contributor

lucasfeliciano commented Jan 28, 2019

Indeed, however if I install with yarn it resolves the dependency.

I think this only happens with npm, can you confirm?

@isaachinman
Copy link
Contributor

That could make sense. I don't use npm, so that would explain why I haven't seen this. As far as I know, the way npm handles peer deps has been a long-standing source of confusion.

I'm open to any solutions anyone might have.

@capellini
Copy link
Contributor

I ran across this comment in the babel docs for useBuiltins:

You may need to specify core-js@2 as a top level dependency in your application if there isn't a core-js dependency or there are multiple versions.

It looks like we may need to pin core-js@2. However, I can't reproduce this, and I use npm.

@andylacko , would you mind posting your 'dependencies' and 'devDependencies' from your package.json? Then, I might be able to create a project that could replicate this issue.

@andylacko
Copy link
Author

npm WARN deprecated kleur@2.0.2: Please upgrade to kleur@3 or migrate to 'ansi-colors' if you prefer the old syntax. Visit <https://github.com/lukeed/kleur/releases/tag/v3.0.0\> for migration path(s).

> fsevents@1.2.7 install /Users/andy/Workspace/js/next-i18next/node_modules/fsevents
> node install

node-pre-gyp WARN Using request for node-pre-gyp https download 
[fsevents] Success: "/Users/andy/Workspace/js/next-i18next/node_modules/fsevents/lib/binding/Release/node-v67-darwin-x64/fse.node" is installed via remote

> husky@1.3.1 install /Users/andy/Workspace/js/next-i18next/node_modules/husky
> node husky install

husky > setting up git hooks
husky > done

> puppeteer@1.11.0 install /Users/andy/Workspace/js/next-i18next/node_modules/puppeteer
> node install.js

Downloading Chromium r609904 - 82.7 Mb [====================] 100% 0.0s 
Chromium downloaded to /Users/andy/Workspace/js/next-i18next/node_modules/puppeteer/.local-chromium/mac-609904

> next-i18next@0.23.0 prepare /Users/andy/Workspace/js/next-i18next
> yarn build

sh: yarn: command not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! next-i18next@0.23.0 prepare: `yarn build`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the next-i18next@0.23.0 prepare script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/andy/.npm/_logs/2019-01-28T10_47_39_788Z-debug.log

after installing npm i -g yarn it succeeded

so the problem is, I have no yarn installed, in package.json, there are some yarn calls, I think, this is the issue

@andylacko
Copy link
Author

{
  "private": true,
  "scripts": {
    "dev": "node server.js",
    "build": "NODE_ENV=production next build",
    "start": "next start",
    "lib": "gulp lib",
    "analyze": "cross-env ANALYZE=1 next build",
    "lint": "eslint actions/ components/ config/ helpers/ layouts/ pages/ reducers/ sagas/",
    "lintfix": "eslint --fix  actions/ components/ config/ helpers/ layouts/ pages/ reducers/ sagas/"
  },
  "dependencies": {
    "adyen-cse-js": "git+https://github.com/Adyen/adyen-cse-web.git#v0.1.21",
    "body-parser": "^1.18.2",
    "compression": "^1.7.3",
    "cookie-parser": "^1.4.3",
    "core-js": "^2.6.3",
    "dotenv": "^4.0.0",
    "draft-js": "^0.10.5",
    "draft-js-buttons": "^2.0.1",
    "draft-js-export-html": "^1.2.0",
    "draft-js-linkify-plugin": "^2.0.1",
    "draft-js-plugins-editor": "^2.1.1",
    "draft-js-static-toolbar-plugin": "^3.0.0",
    "draftjs-to-html": "^0.8.4",
    "es6-promise": "^4.2.5",
    "express": "^4.16.4",
    "graceful-fs": "^4.1.15",
    "gulp": "^3.9.1",
    "gulp-clean-css": "^3.10.0",
    "gulp-concat": "^2.6.1",
    "gulp-sass": "^3.1.0",
    "humps": "^2.0.1",
    "i18next": "^14.0.1",
    "ismobilejs": "^0.4.1",
    "isomorphic-fetch": "2.2.1",
    "js-cookie": "^2.2.0",
    "moment": "^2.22.2",
    "next": "^7.0.2",
    "next-i18next": "^0.23.0",
    "next-redux-saga": "^3.0.0",
    "next-redux-wrapper": "^2.0.0",
    "next-routes": "^1.4.2",
    "node-sass": "^4.9.3",
    "normalize.css": "^8.0.1",
    "query-string": "^6.2.0",
    "react": "^16.5.2",
    "react-addons-css-transition-group": "^15.6.2",
    "react-custom-scrollbars": "^4.2.1",
    "react-dates": "^18.2.2",
    "react-dom": "^16.5.2",
    "react-draft-wysiwyg": "^1.12.13",
    "react-dropzone": "^7.0.1",
    "react-google-invisible-recaptcha": "*",
    "react-google-tag-manager": "^2.2.1",
    "react-inlinesvg": "^0.8.2",
    "react-redux": "^5.1.1",
    "react-select": "^1.*",
    "react-spinners": "^0.4.7",
    "react-stickynode": "^2.1.0",
    "react-tippy": "^1.2.3",
    "react-toastify": "^3.*",
    "react-vis": "^1.11.4",
    "redux": "^4.0.1",
    "redux-devtools-extension": "^2.13.5",
    "redux-saga": "^0.15.4",
    "request": "^2.88.0",
    "semaphore-async-await": "^1.5.1",
    "smoothscroll-polyfill": "^0.4.0",
    "sweetalert2-react": "^0.5.0",
    "url": "^0.11.0",
    "winston": "^3.2.0"
  },
  "devDependencies": {
    "babel-eslint": "^8.2.2",
    "cross-env": "^5.1.4",
    "eslint": "^5.12.0",
    "eslint-config-airbnb": "^16.*",
    "eslint-plugin-import": "^2.14.0",
    "eslint-plugin-jsx-a11y": "^6.0.3",
    "eslint-plugin-react": "^7.11.1",
    "faker": "^4.1.0",
    "webpack-bundle-analyzer": "^2.11.1"
  }
}

@isaachinman
Copy link
Contributor

isaachinman commented Jan 28, 2019

However, I can't reproduce this, and I use npm

@capellini Probably because you don't have a conflicting dep and @andylacko does. Thanks for finding that info in the docs.

@andylacko I've added core-js as an explicit dep and published v0.23.1. Can you let me know if this resolves the issue?

@capellini
Copy link
Contributor

Probably because you don't have a conflicting dep and @andylacko does

Yes, specifically draft-js@^0.10.5

screenshot from 2019-01-28 06-46-32

We may be able to get away with just specifying core-js@^2.5.0 as a dependency. But, assuming that next-i18next is a top-level dependency, a peer dependency is technically the best way to specify this, as the correct version of core-js would also be at the top-level.

@isaachinman - It may be better to:

  1. make core-js a peer dependency with the lowest compatible version possible (core-js@^2.5.0)
  2. move the @babel/polyfill to dev dependencies
  3. add core-js@^2.5.0 to dev dependencies

This will put the onus of determining which version of core-js/@babel/polyfill to use on the user. Keeping it as a dev dependency on our project allows us to still use it for development, as needed. Of course, then users would have to install core-js on their own (and manually resolving peer dependencies can be a pain, at times). So instead of npm install/yarn add next-i18next, they would have to npm install/yarn add next-i18next core-js@^2.5.

Considering the way that @babel/polyfill works, I think the peer dependency is the only real way to fix this.

@isaachinman
Copy link
Contributor

I follow the bit about moving core-js to a peer, but not about moving @babel/polyfill to a dev dep. How does that help? To be clear, @babel/polyfill is used at runtime.

@capellini
Copy link
Contributor

@babel/polyfill is used at runtime.

Ah, right. Then it wouldn't make sense to move it to a dev dependency. Would it then make sense to also have @babel/polyfill as a peer dependency only?

@isaachinman
Copy link
Contributor

Would it then make sense to also have @babel/polyfill as a peer dependency only?

As far as I know, we don't depend on any specific version of @babel/polyfill. Moreover, I'm not even sure if we depend upon any specific version of core-js. This would be worth finding out.

The original problem in this issue is that core-js was absent entirely, I believe.

@capellini
Copy link
Contributor

As far as I know, we don't depend on any specific version of @babel/polyfill.

No specific version, but we do have it as a dependency in our package.json. If it's strictly used at runtime, can we just list it as a peer dep?

Moreover, I'm not even sure if we depend upon any specific version of core-js.

In this case, since we evidently need core-js/modules/es7.symbol.async-iterator somewhere in our utils, we need to have core-js@^2.5.0.

The original problem in this issue is that core-js was absent entirely, I believe.

When I installed a dummy project with the same dependencies as @andylacko, core-js was present in both the project root and in downstream package node_modules directories.

The problem was that the version of core-js that was referenced (the one in the project root) didn't have the core-js/modules/es7.symbol.async-iterator file. I assume that @andylacko got past this by doing an npm install core-js, since the latest version is listed in his dependencies.

Using @andylacko's deps (except for the core-js dep), if you installed with npm the root version of core-js was at v1.2.7 because draft-js depended on fbjs, which in turn depended that version of core-js. Then @babel/polyfill's node_modules had core-js@latest because of several dependencies on it.

However, if you used yarn the root node_modules directory contained core-js@latest and fbjs's node_modules contained core-js v1.2.7.

The different locations of core-js and which one is in the root of the project directory matters because when babel polyfills an async iterator, it replaces the line of code that uses an async interator with something like:

import 'core-js/modules/es7.symbol.async-iterator';
// ... polyfilled code

And so node uses the core-js from the top of the project tree. If the version that is found does not have the file we need, the above error is thrown.

Playing around with yarn and npm a bit more (with contrived examples), I also managed to get npm to install the latest version of core-js on the project root, but not yarn and also ran into a situation where they both did not install the latest version on project root.

@isaachinman
Copy link
Contributor

can we just list it as a peer dep

Sure.

we evidently need core-js/modules/es7.symbol.async-iterator somewhere in our utils, we need to have core-js@^2.5.0

OK.

I'm open to any sensible PRs on this, but we need to be very careful that we don't break installs outright. This package needs to work with the latest versions of npm and yarn equally well.

@capellini
Copy link
Contributor

I agree. I'd like to take a little more time to research npm and yarn dependency resolution, peer dependencies, as well as babel and use of it with next-i18next different projects before I submit the PR.

@andylacko and @lucasfeliciano - the short-term fix is to install core-js@^2.5.0 in your projects. That should work, but please let me know if it doesn't.

Incidentally @lucasfeliciano, would you mind posting the output of yarn why core-js just so I can confirm that you're facing the same problem and not some other one?

@isaachinman
Copy link
Contributor

@capellini The short term fix was v0.23.1.

@isaachinman
Copy link
Contributor

@andylacko Can you please chime in and let us know if v0.23.1 fixed your issue?

If so, we'll close this issue in favour of #136 as a longer-term solution.

@andylacko
Copy link
Author

@isaachinman , it works 馃憣

@isaachinman
Copy link
Contributor

Excellent. We'll now close this and track a peer-deps solution via #136.

@lucasfeliciano
Copy link
Contributor

@isaachinman after v0.26.0 this is back for me

image

Probably related to 4bf9d37

@isaachinman
Copy link
Contributor

@lucasfeliciano Right. I need a way to reproduce. Instead of including core-js, we're going to not polyfill. You're seeing this when doing installs via npm, right?

@lucasfeliciano
Copy link
Contributor

Correct, installing via npm.
I think that is enough to reproduce if not let me know and I try to create a repo where this happens

@isaachinman
Copy link
Contributor

isaachinman commented Feb 5, 2019

@lucasfeliciano Is that just dev, or prod too? I installed next-i18next in an empty dir via npm and got it up and running without any issues.

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

No branches or pull requests

4 participants