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

Error in ./.nuxt/router.js #4839

Closed
Skriptach opened this issue Jan 23, 2019 · 14 comments
Closed

Error in ./.nuxt/router.js #4839

Skriptach opened this issue Jan 23, 2019 · 14 comments

Comments

@Skriptach
Copy link

Version

v2.3.4

Reproduction link

http://itstoobig.code

Steps to reproduce

I'm trying to migrate Nuxt from 1.4.2 to current latest 2.3.4. I went through migration instruction steps. But still getting build error

Actual ./.nuxt/router.js content of that part:

import Vue from 'vue'
import Router from 'vue-router'
import { interopDefault } from './utils'

const _495307ce = () => interopDefault(import('../pages/account/index.vue' /* webpackChunkName: "pages/account/index" */))
const _39025db0 = () => interopDefault(import('../pages/banners.vue' /* webpackChunkName: "pages/banners" */))
const _df2f0e94 = () => interopDefault(import('../pages/brands/index.vue' /* webpackChunkName: "pages/brands/index" */))
const _7e887586 = () => interopDefault(import('../pages/categories/index.vue' /* webpackChunkName: "pages/categories/index" */))
const _16d506f9 = () => interopDefault(import('../pages/coupons/index.vue' /* webpackChunkName: "pages/coupons/index" */))
...

nuxt.config.js:

import dotenv from 'dotenv'
import { PROXY, WS_URL, head, manifest } from './config'

dotenv.config();

export default {
    mode: 'spa',
    head, manifest,
    loading: '~/components/LoadingBar.vue',
    css: [
        'vuetify/src/stylus/main.styl',
        '~/assets/main.css',
        '~/assets/transitions.css',
        '~/assets/fonts/Elegant-Garamond-Regular.css',
    ],
    plugins: [
        '~/plugins/html51.js',
        '~/plugins/axios.js',
        '~/plugins/socket.js',
        '~/plugins/vuetify.js',
        '~/plugins/filters.js',
        '~plugins/social.js',
        { src: '~/plugins/lazy.js' },
        { src: '~/plugins/validate.js' },
        { src: '~/plugins/scroll.js', ssr: false },
        { src: '~/plugins/line-chart.js', ssr: false },
        { src: '~/plugins/i18n.js', ssr: false },
        { src: '~/plugins/sweetalert2.js', ssr: false },
        { src: '~plugins/maps.js', ssr: false }
    ],
    modules: [
        '@nuxtjs/axios',
        '@nuxtjs/dotenv',
    ],
    axios: {
        proxy: true,
        credentials: true,
    },
    proxy: {
        '/api': PROXY,
        '/auth': PROXY
    },
    generate: {
        dir: 'dist/public'
    },
    workbox: {
        runtimeCaching: [
            {
                urlPattern: PROXY + '/groceries/.*',
                handler: 'cacheFirst',
                method: 'GET',
                strategyOptions: { cacheableResponse: { statuses: [0, 200] } }
            },
            {
                urlPattern: 'https://fonts.googleapis.com/.*',
                handler: 'cacheFirst',
                method: 'GET',
                strategyOptions: { cacheableResponse: { statuses: [0, 200] } }
            },
            {
                urlPattern: 'https://fonts.gstatic.com/.*',
                handler: 'cacheFirst',
                method: 'GET',
                strategyOptions: { cacheableResponse: { statuses: [0, 200] } }
            }
        ]
    },
    router: {
        middleware: ['init-app'] // Should be called on every page request.
    },

    /*
    ** Build configuration
    */
    build: {
        /*
        ** You can extend webpack config here
        */
        extend(config, ctx) {
            if (ctx.isServer) {
                config.externals = [
                    nodeExternals({
                        whitelist: [/^vuetify/]
                    })
                ]
                // This instructs Webpack to include `vue2-google-maps`'s Vue files
                // for server-side rendering
                config.externals.splice(0, 0, function (context, request, callback) {
                    if (/^vue2-google-maps($|\/)/.test(request)) {
                        callback(null, false)
                    } else {
                        callback()
                    }
                })
            }
        }
    },
    env: {
        WS_URL: WS_URL || PROXY, // This will allow us to configure plugins/socket.js
        PROXY: PROXY
    }
}

tsconfig.js

{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/server",
    "baseUrl": "src",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "module": "commonjs",
    "allowSyntheticDefaultImports": true,
    "noEmitHelpers": true,
    "importHelpers": true,
    "strictNullChecks": false,
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2016",
      "dom"
    ],
    "types": [
      "hammerjs",
      "node"
    ]
  },
  "exclude": [
    "node_modules",
    "dist"
  ],
  "awesomeTypescriptLoaderOptions": {
    "forkChecker": true,
    "useWebpackText": true
  },
  "buildOnSave": false
}

node version: 10.15.0
npm version: 6.6.0

What is expected ?

Build without errors

What is actually happening?

Screenshot from 2019-01-23 17-22-52.png

This bug report is available on Nuxt community (#c8535)
@ghost ghost added the cmty:bug-report label Jan 23, 2019
@pehlse
Copy link

pehlse commented Jan 23, 2019

I was with the same problem, I decided to install the dependencies with yarn and it worked

@manniL
Copy link
Member

manniL commented Jan 23, 2019

It's an NPM bug and not related to nuxt.

Use yarn in the meantime ☺️

More info:
webpack/webpack#8656

@aaaguirrep
Copy link

Hi,
Can i have npm and yarn installed simultaneously?

@manniL
Copy link
Member

manniL commented Jan 27, 2019

Sure

@koresar
Copy link

koresar commented Jan 29, 2019

I encounter the same error in v2.4.0. Although, we can't go yarn as a team. This bug isn't yet "resolved" as to me.

@manniL
Copy link
Member

manniL commented Jan 29, 2019

@koresar

  1. It is not a Nuxt bug at all. The only reason why this issue is still open is for visibility
  2. You can resolve it with NPM as well (read the linked Webpack bug)
  3. It's "resolved" as there is a workaround ☺️

@koresar
Copy link

koresar commented Jan 29, 2019

My apologies @manniL. I should have paid better attention. Thank you for keeping it open.

For all the other "I don't have time to read all the comments. Give me the fix" people like me here is the workaround (until npm fixes their thing).

rm -rf node_modules package-lock.json
npm i
npm update acorn --depth 20
npm dedupe

@manniL
Copy link
Member

manniL commented Jan 29, 2019

@koresar No problem ☺️

We also added that to the release notes (over at https://github.com/nuxt/nuxt.js/releases/tag/v2.4.0) 🙌

@manniL manniL changed the title nuxt build error in ./.nuxt/router.js Error in ./.nuxt/router.js [SOLVED] Jan 29, 2019
@manniL manniL changed the title Error in ./.nuxt/router.js [SOLVED] Error in ./.nuxt/router.js Jan 29, 2019
@fbrbovic
Copy link

fbrbovic commented Jan 29, 2019

For anyone else who might be in same situation. I've tried various combinations of the above mentioned commands and none of them work for my setup. If you tried all the above and still having the same error try the following.
This is the one that worked for me.

rm -rf node_modules package-lock.json
# you may or may not need to do a full npm cache clean - I did in my case
npm cache clean --force
npm install webpack@4.28.4 --save-dev --save-exact
npm install acorn-dynamic-import@4.0.0 --save-dev
npm install acorn@6.0.5 --save-dev
npm i
npm update acorn --depth 20
npm dedupe

@seth100
Copy link

seth100 commented Jan 29, 2019

For anyone else who might be in same situation. I've tried various combinations of the above mentioned commands and none of them work for my setup. If you tried all the above and still having the same error try the following.
This is the one that worked for me.

rm -rf node_modules package-lock.json
# you may or may not need to do a full npm cache clean - I did in my case
npm cache clean --force
npm install webpack@4.28.4 --save-dev --save-exact
npm install acorn-dynamic-import@4.0.0 --save-dev
npm install acorn@6.0.5 --save-dev
npm i
npm update acorn --depth 20
npm dedupe

thanks that worked to me.
But when the bug will be solved by Webpack team, should I remove those acorn-dynamic-import, acorn and update webpack to latest version or what?

Thanks

@manniL manniL pinned this issue Jan 30, 2019
@manniL
Copy link
Member

manniL commented Jan 30, 2019

Clsing here and pinned the bug until npm/cli#147 is merged and released

More info:
webpack/webpack#8656

@manniL manniL closed this as completed Jan 30, 2019
@nusendra
Copy link

nusendra commented Feb 2, 2019

Yarn will solve your problem

stormwarning added a commit to stormwarning/polychroma that referenced this issue Feb 7, 2019
Includes an upgrade to latest major version of chroma.js, as well as some
code formatting changes.

Removes `vue-slider-component` in favour of an internal range input that
is SSR-compatible. Currently built with Sass for styles, pending a
refactor/redesign.

`yarn.lock` replaces `package-lock.json` pending a solution to this
[peerDependencies issue](https://npm.community/t/packages-with-peerdependencies-are-incorrectly-hoisted/4794) (see this [nuxt.js issue](nuxt/nuxt#4839) for more info).
@williamchong
Copy link

FYI npm is reverting their fix npm/cli#152

yysaki added a commit to yysaki/shikibetsuhyo that referenced this issue Mar 3, 2019
@manastalukdar
Copy link

This issue also occurred on upgrading to nuxt 2.5.1 from 2.4.3, mitigated by outlined workaround.

lefuturiste added a commit to retrobox/web that referenced this issue Jun 30, 2019
fix: because of issue with webpack and npm we have a package resolution issue with nuxt. So we have to move to yarn for now, this is the easiest way to resolve this issue (workaround). nuxt/nuxt#4839
fix: security fix via npm audit --force
package change: move from markdown-loader@4.0.0 to markdown-loader@5.0.0 this major change in package version can lead to potentials error in code but this was required to pass the npm audit (resolved with npm audit --force)
fix: fix vue-directive-tooltip issue
package change: moved from vue-directive-tooltip to lefuturiste-vue-directive-tooltip because of a useless and not working postinstall script. Now on a forked package (follow the issue on the repository and be ready to revert to the original package). This can lead to potentials issue with the code later. hekigan/vue-directive-tooltip#44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests