Do the fresh install of the Nuxt(via cli) with the following options:
After running the npm run dev I am getting the error:
ERROR Failed to compile with 3 errors
These dependencies were not found:
* core-js/library/fn/object/assign in ./node_modules/babel-runtime/core-js/object/assign.js
* core-js/library/fn/symbol in ./node_modules/babel-runtime/core-js/symbol.js
* core-js/library/fn/symbol/iterator in ./node_modules/babel-runtime/core-js/symbol/iterator.js
Clean install without errors
Fails to compile because of missing dependencies
We are having similar issues with upgrading from 2.4.5 to 2.5.0 when building the BootstrapVue docs:
SyntaxError: Unexpected token export
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:617:28)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at r (/root/bootstrap-vue/node_modules/vue-server-renderer/build.dev.js:9295:16)
at Object.<anonymous> (webpack:/external "@babel/runtime/helpers/esm/asyncToGenerator":1:0)
at o (webpack/bootstrap:36:0)
at Module.<anonymous> (.nuxt/middleware.js:1:19)
at o (webpack/bootstrap:36:0)
at Object.<anonymous> (node_modules/@nuxt/webpack/node_modules/core-js/internals/own-keys.js:4:43)
at o (webpack/bootstrap:36:0)
And getting warning about core-js
version not being specified:
WARNING: We noticed you're using the useBuiltIns option without declaring a core-js version.
Currently, we assume version 2.x when no version is passed. Since this default version will
likely change in future versions of Babel, we recommend explicitly setting the core-js
version you are using via the corejs option.
You should also be sure that the version you pass to the corejs option matches the version
specified in your package.json's dependencies section. If it doesn't, you need to run one
of the following commands:
npm install --save core-js@2 npm install --save core-js@3
yarn add core-js@2 yarn add core-js@3
@andrewgorpenko try:
add /lib in ~/plugins/element-ui.js
import Vue from 'vue'
import Element from 'element-ui/lib'
import locale from 'element-ui/lib/locale/lang/en'
export default () => {
Vue.use(Element, { locale })
}
as temporary solution, while element-ui a plugin for nuxt not updated
This works fine with this temporary fix, thanks.
Thanks for reporting this issue. All inconsistencies should be resolved with v2.5.1. Please upgrade and ping us if still, any problem exists regarding core-js.
Hey @pi0 Thanks for everything and the quick response.
Still getting a lot of core-js issues with v2.5.1 upgrade.
@digitalcrafted Do you have a babel.config.js
or .babelrc
file in your project? Otherwise is there any chance you can share the project with us or giving more details?
PS: Cleaning up yarn.lock
/package-lock.json
may help.
Thanks @pi0 => Cleaning up package-lock.json
did it.
I am still getting the same errors... removed everything node_modules
, .nuxt
, yarn.lock
, tried with npm instead of yarn and still am getting this error.
I already checked file by file from a clean npx create-nuxt-app
install and all files are ok, including the package.json and .babelrc
@rodrigopedra Can you please manually add core-js@2
in your project?
Tried and still getting the same error, below are my package.json
dependencies (with core-js added):
~json
{
"dependencies": {
"@nuxtjs/auth": "^4.5.3",
"@nuxtjs/axios": "^5.3.6",
"@nuxtjs/dotenv": "^1.3.0",
"@nuxtjs/proxy": "^1.3.3",
"@nuxtjs/pwa": "^2.6.0",
"axios": "^0.18.0",
"core-js": "2",
"cross-env": "^5.2.0",
"date-fns": "^1.30.1",
"nuxt": "^2.4.0",
"portal-vue": "^1.5.1",
"vue-avatar": "^2.1.7",
"vue-svg-loader": "^0.12.0"
},
"devDependencies": {
"@nuxtjs/eslint-config": "^0.0.1",
"@vue/test-utils": "^1.0.0-beta.27",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "^8.2.1",
"babel-jest": "^23.6.0",
"email-validator": "^2.0.4",
"eslint": "^5.0.1",
"eslint-config-prettier": "^3.1.0",
"eslint-config-standard": ">=12.0.0",
"eslint-loader": "^2.0.0",
"eslint-plugin-import": ">=2.14.0",
"eslint-plugin-jest": ">=21.24.1",
"eslint-plugin-node": ">=7.0.1",
"eslint-plugin-prettier": "2.6.2",
"eslint-plugin-promise": ">=4.0.1",
"eslint-plugin-standard": ">=4.0.0",
"eslint-plugin-vue": "^5.2.0",
"jest": "^23.6.0",
"node-sass": "^4.11.0",
"nodemon": "^1.18.9",
"prettier": "1.14.3",
"sass": "^1.17.0",
"sass-loader": "^7.1.0",
"vue-jest": "^3.0.2"
}
}
~
@rodrigopedra I tried provided package.json locally with yarn and it was working fine. What error do you get? Is it related to a specific library? Sharing full error may help.
Hi @pi0 thanks for the patience, here is the browser output:
SyntaxError
Unexpected token export
vm.js:80:10
createScript
vm.js:139:10
Object.runInThisContext
module.js:617:28
Module._compile
module.js:664:10
Module._extensions..js
module.js:566:32
Module.load
module.js:506:12
tryModuleLoad
module.js:498:3
Module._load
module.js:597:17
Module.require
internal/module.js:11:18
require
webpack:/external "@babel/runtime/helpers/esm/defineProperty":1:
Object.@babel/runtime/helpers/esm/defineProperty
webpack/bootstrap:25:
__webpack_require__
server.js:8327:99
Module../services/AuthService.js
webpack/bootstrap:25:
__webpack_require__
store/users.js:1:
Module../store/users.js
webpack/bootstrap:25:
__webpack_require__
The only userland file it is complaining about is a store. I checked this store in my code and it imports a class that defined a static property. Maybe some change disallowed this feature.
These are the changes I made in my code, in case someone faces the same issue:
// /store/users.js
import AuthService from '@/services/AuthService';
// state, mutations, actions, ...
export const getters = {
socialLoginUrl() {
return AuthService.SOCIAL_LOGIN_URL;
},
};
// /sevice/AuthService.js
export default class AuthService {
static SOCIAL_LOGIN_URL = '/social/login'; // this is where the error occurs
// other class methods
}
// /store/users.js
import AuthService, { SOCIAL_LOGIN_URL } from '@/services/AuthService';
// state, mutations, actions, ...
export const getters = {
socialLoginUrl() {
return SOCIAL_LOGIN_URL;
},
};
// /sevice/AuthService.js
export const SOCIAL_LOGIN_URL = '/social/login'; // no more errors
export default class AuthService {
// other class methods
}
@rodrigopedra I've seen similar "Unexpected token export" error in projects having babel.config.js
file. Do you have one? And if yes, can you please remove if it to see it works?
The only babel file I have is the .babelrc
generated by create-nuxt-app
Sorry if I wasn't clear before, but I got it working from changing the static class constant to a named const export.
See the before and after in my previous comment, after that change everything is working for me.
So now I'm stick with 2.5.0 if we "need" to stay with core-js3.0? This is kind of unsatisfying. Could we solve this somehow by a "flag" to use core js 3 via "opt in"?
@simllll 2.5.1 rollbacked core-js 2
I also reported a similar mistake.
Failed to compile with 6 errors friendly-errors 17:51:56
These dependencies were not found: friendly-errors 17:51:56
friendly-errors 17:51:56
this is the package.json
"dependencies": {
"axios": "^0.18.0",
"element-ui": "^2.4.11",
"js-cookie": "^2.2.0",
"nuxt": "2.5.0",
"nuxt-clipboard2": "^0.2.1",
"nuxt-stripe-module-https": "^1.0.0",
"rollup": "^0.67.4",
"vant": "^1.4.2",
"vue-i18n": "^8.3.1",
"vue-lazyload": "^1.2.6",
"vue-paypal-checkout": "^3.2.0",
"vue-social-sharing": "^2.3.3",
"vuex-persistedstate": "^2.5.4"
},
"devDependencies": {
"@nuxtjs/axios": "^5.3.4",
"@vue/test-utils": "^1.0.0-beta.29",
"autoprefixer": "^9.3.1",
"babel-core": "^6.26.3",
"babel-eslint": "^10.0.1",
"babel-jest": "^24.7.1",
"babel-plugin-component": "^1.1.1",
"babel-plugin-import": "^1.11.0",
"babel-preset-env": "^1.7.0",
"babel-preset-es2015": "^6.24.1",
"cross-env": "^5.2.0",
"eslint": "^4.19.1",
"eslint-friendly-formatter": "^4.0.1",
"eslint-loader": "^2.1.1",
"eslint-plugin-vue": "^4.0.0",
"identity-obj-proxy": "^3.0.0",
"jest": "^24.7.1",
"jest-transform-stub": "^2.0.0",
"node-sass": "^4.10.0",
"nuxt-sass-resources-loader": "^2.0.5",
"postcss-pxtorem": "^4.0.1",
"sass-loader": "^7.1.0",
"vue-jest": "^3.0.4"
}
I also reported a similar mistake.
Failed to compile with 6 errors friendly-errors 17:51:56These dependencies were not found: friendly-errors 17:51:56
friendly-errors 17:51:56
- core-js/library/fn/get-iterator in ./node_modules/[email protected]@babel-runtime/core-js/get-iterator.js friendly-errors 17:51:56
- core-js/library/fn/is-iterable in ./node_modules/[email protected]@babel-runtime/core-js/is-iterable.js friendly-errors 17:51:56
- core-js/library/fn/object/assign in ./node_modules/[email protected]@babel-runtime/core-js/object/assign.js friendly-errors 17:51:56
- core-js/library/fn/object/keys in ./node_modules/[email protected]@babel-runtime/core-js/object/keys.js friendly-errors 17:51:56
- core-js/library/fn/symbol in ./node_modules/[email protected]@babel-runtime/core-js/symbol.js friendly-errors 17:51:56
- core-js/library/fn/symbol/iterator in ./node_modules/[email protected]@babel-runtime/core-js/symbol/iterator.js friendly-errors 17:51:56
friendly-errors 17:51:56
To install them, you can run: npm install --save core-js/library/fn/get-iterator core-js/library/fn/is-iterable core-js/library/fn/object/assign core-js/library/fn/object/keys core-js/library/fn/symbol core-js/library/fn/symbol/iteratorthis is the package.json
"dependencies": { "axios": "^0.18.0", "element-ui": "^2.4.11", "js-cookie": "^2.2.0", "nuxt": "2.5.0", "nuxt-clipboard2": "^0.2.1", "nuxt-stripe-module-https": "^1.0.0", "rollup": "^0.67.4", "vant": "^1.4.2", "vue-i18n": "^8.3.1", "vue-lazyload": "^1.2.6", "vue-paypal-checkout": "^3.2.0", "vue-social-sharing": "^2.3.3", "vuex-persistedstate": "^2.5.4" }, "devDependencies": { "@nuxtjs/axios": "^5.3.4", "@vue/test-utils": "^1.0.0-beta.29", "autoprefixer": "^9.3.1", "babel-core": "^6.26.3", "babel-eslint": "^10.0.1", "babel-jest": "^24.7.1", "babel-plugin-component": "^1.1.1", "babel-plugin-import": "^1.11.0", "babel-preset-env": "^1.7.0", "babel-preset-es2015": "^6.24.1", "cross-env": "^5.2.0", "eslint": "^4.19.1", "eslint-friendly-formatter": "^4.0.1", "eslint-loader": "^2.1.1", "eslint-plugin-vue": "^4.0.0", "identity-obj-proxy": "^3.0.0", "jest": "^24.7.1", "jest-transform-stub": "^2.0.0", "node-sass": "^4.10.0", "nuxt-sass-resources-loader": "^2.0.5", "postcss-pxtorem": "^4.0.1", "sass-loader": "^7.1.0", "vue-jest": "^3.0.4" }
remove .nuxt
For the benefit of people coming here from search engine, this error can trigger depending on what dependencies one has installed and can be fixed by explicitly installing core-js@2
dependency.
Here is the solution:
https://nuxtjs.org/guide/release-notes#core-js
Most helpful comment
For the benefit of people coming here from search engine, this error can trigger depending on what dependencies one has installed and can be fixed by explicitly installing
core-js@2
dependency.