Skip to content

Unexpected token '.' in Nuxt JS #178

@Sanjay-Sahu-Bandla

Description

@Sanjay-Sahu-Bandla

image

I'm getting the above Unexpected token '.' error while working with pqgrid in nuxt js. Below are the dependencies that my project has

  "dependencies": {
    "@nuxtjs/auth-next": "5.0.0-1643791578.532b3d6",
    "@nuxtjs/axios": "^5.13.6",
    "@types/jquery": "^3.5.14",
    "@types/jqueryui": "^1.12.16",
    "ag-grid-community": "^27.0.1",
    "ag-grid-enterprise": "^27.0.1",
    "ag-grid-vue": "^27.0.0",
    "aos": "^2.3.4",
    "axios": "^0.26.0",
    "bootstrap": "^4.6.1",
    "bootstrap-vue": "^2.21.2",
    "core-js": "^3.19.3",
    "font-awesome": "^4.7.0",
    "intl-tel-input": "^17.0.15",
    "jquery": "^3.6.0",
    "jquery-ui-pack": "^1.12.3",
    "jszip": "^3.7.1",
    "nuxt": "^2.15.8",
    "pqgrid": "^8.2.1",
    "vee-validate": "^3.4.14",
    "vue": "^2.6.14",
    "vue-server-renderer": "^2.6.14",
    "vue-template-compiler": "^2.6.14",
    "webpack": "^4.46.0"
  },
  "devDependencies": {
    "@babel/eslint-parser": "^7.16.3",
    "@nuxtjs/eslint-config": "^8.0.0",
    "@nuxtjs/eslint-module": "^3.0.2",
    "eslint": "^8.4.1",
    "eslint-config-prettier": "^8.3.0",
    "eslint-plugin-nuxt": "^3.1.0",
    "eslint-plugin-vue": "^8.2.0",
    "prettier": "^2.5.1"
  }
  • When I have the same packages in a fresh Vue Js project, it's working perfectly fine. But using them in a Nuxt Js project it's throwing this unexpected token '.' error.
  • When I run it from modules: ['pqgrid'] located in nuxt.config.js, it's giving a runtime error shown below

image

Steps to reproduce

  1. Install a Nuxt JS app using the command npm init nuxt-app app-name

  2. Install the required packages using npm i pqgrid jquery jquery-ui-pack @types/jquery @types/jqueryui jszip

  3. Add the following code in the pages/index.vue file

<template>
  <Tutorial />
</template>

<script>

import pq from 'pqgrid'

export default {

  name: 'IndexPage',
  mounted () {
    console.log(pq)
  }
}
</script>
  1. Now run the Nuxt app with npm run dev
  2. Open the localhost URL in the browser, it will show the unexpected token error '.'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions