https://github.com/kabalage/nuxt-core-js-problem
> yarn install
> cd ui/landing
> yarn run dev
I expect that @nuxt/babel-preset-app
would use the core-js
version it needed. (node_modules/@nuxt/babel-preset-app/node_modules/core-js
)
It resolves to the core-js
version installed by other packages. (node_modules/core-js
)
This results in errors like:
These dependencies were not found:
* core-js/modules/es6.array.find in ./.nuxt/client.js
* core-js/modules/es6.array.iterator in ./.nuxt/client.js
* core-js/modules/es6.date.to-string in ./.nuxt/utils.js
* core-js/modules/es6.function.name in ./.nuxt/client.js
...
We have multiple ui projects for one app and others are using the newer 3.x.x
version of core-js
. We implemented our landing page using nuxt because it supports static site generation but have run into this problem when trying replace the old landing page implementation in our monorepo managed by yarn workspaces.
I'm not sure what is happening in nuxt
, I would like some insight if it is something fixable with configuration.
If you search on https://nuxtjs.org for core-js you will find these tips about core-js from the release log of v2.6.0
: https://nuxtjs.org/guide/release-notes#core-js
Unfortunately, we can't do anything for this issue for supporting multiple core-js versions. The reason is that it is not @nuxt/vue-app
picking core-js
but webpack which prefers main node_modules
... We tried using aliases but it was not fully functional as core-js 2/3 structures are different...
BTW OH! I just thought about a newer idea to make webpack searching for @nuxt/vue-app/node_modules
first! Will try to see how it works.
For now as @pimlie mentioned it would be better to follow core-js instructions and upgrading to 3.
Thank you for your responses. I could solve the core-js issue using @pimlie 's suggestion but unfortunately I encountered webpack loader problems afterwards which similarly may have been caused by the different package versions used by the new nuxt app and the rest. It could not load ./.nuxt/components/nuxt-error.vue
in ./.nuxt/index.vue
or something similar. (I'm writing this from memory, sorry...) If you're interested in the details, I could check again.
I ended up nohoist-ing the nuxt app package so yarn install
will install all its dependencies locally under its own directory which completely solved the dependency issues. Maybe using hoisting for every package is not worth the hassle and I understand why these kinds of problems can't always be fixed.
Same problem. I did what he said @kabalage.
rm -rf node_modules && yarn
This worked for me.
Thanks for your contribution to Nuxt.js!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you would like this issue to remain open:
Issues that are labeled as pending
will not be automatically marked as stale.
I have the same problem but rm -rf node_modules && npm i
didn't work for me. Is there any other workaround for this?
I have the same problem but
rm -rf node_modules && npm i
didn't work for me. Is there any other workaround for this?
Do this:
rm -rf node_modules && yarn
rm -rf yarn.lock
npm run dev
It is caused due to nohoist being done by npm
I have the same problem but
rm -rf node_modules && npm i
didn't work for me. Is there any other workaround for this?Do this:
rm -rf node_modules && yarn rm -rf yarn.lock npm run dev
It is caused due to nohoist being done by npm
I'm sorry, this didn't work for me.
This worked: yarn add -D core-js@2 @babel/runtime-corejs2
This suggestion was taken from this link: https://nuxtjs.org/guide/release-notes#-code-core-js-2-code-
Most helpful comment
I'm sorry, this didn't work for me.
This worked:
yarn add -D core-js@2 @babel/runtime-corejs2
This suggestion was taken from this link: https://nuxtjs.org/guide/release-notes#-code-core-js-2-code-