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

require() of ES Module #372

Closed
blackslayR opened this issue Aug 29, 2023 · 4 comments
Closed

require() of ES Module #372

blackslayR opened this issue Aug 29, 2023 · 4 comments

Comments

@blackslayR
Copy link

blackslayR commented Aug 29, 2023

require() of ES Module C:\path\node_modules\query-string\index.js from C:\path\client\node_modules\vue-server-renderer\build.dev.js not supported. Instead change the require of index.js in C:\path\client\node_modules\vue-server-renderer\build.dev.js to a dynamic import() which is available in all CommonJS modules.

this is my own package.json file

  "name": "client",
  "version": "1.0.0",
  "description": "Nuxt.js project",
  "author": "",
  "private": true,
  "type": "module",
  "scripts": {
    "dev": "nuxt",
    "build": "nuxt build",
    "start": "nuxt start",
    "generate": "nuxt generate",
    "lint": "eslint --ext .js,.vue --ignore-path .gitignore .",
    "precommit": "npm run lint"
  },
  "dependencies": {
    "@nuxtjs/auth": "^4.9.1",
    "@nuxtjs/axios": "^5.13.6",
    "flowbite": "^1.8.1",
    "nuxt": "^2.0.0",
    "query-string": "^8.1.0"
  },
  "devDependencies": {
    "autoprefixer": "^10.4.15",
    "babel-eslint": "^10.0.1",
    "eslint": "^4.19.1",
    "eslint-friendly-formatter": "^4.0.1",
    "eslint-loader": "^2.1.1",
    "eslint-plugin-vue": "^4.0.0",
    "postcss": "^8.4.28",
    "tailwindcss": "^3.3.3"
  }
}

This is my code

import queryString from 'query-string'

/// Rest of the code

export const actions = {
    async getCart ({ commit, state }) {
        let query = {}

        if (state.shipping) {
          query.shipping_method_id = state.shipping.id
        }
    
        let response = await this.$axios.$get(`cart?${queryString.stringify(query)}`)


// Rest of the code

i have tried adding "type": "module" to my own package.json file, and even downgraded to other version ended up with even more errors.

@sindresorhus
Copy link
Owner

@sindresorhus sindresorhus closed this as not planned Won't fix, can't repro, duplicate, stale Aug 29, 2023
@sindresorhus
Copy link
Owner

You probably need to enable ESM in your Vue/Nuxt server. This package uses correct ESM config, so the problem is with your build tool or config.

@bertyhell
Copy link

You can also downgrade to v7.x.x which is not an ESM build yet

@Dakuan
Copy link

Dakuan commented Feb 22, 2024

@bertyhell thanks! all these ESM packages are ruining ts + node projects

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