require is not defined in ES module scope, you can use import instead
See original GitHub issueEnvironment
- Operating System:
Darwin
- Node Version:
v14.20.0
- Nuxt Version:
3.0.0-rc.8
- Package Manager:
npm@6.14.17
- Builder:
vite
- User Config:
css
,runtimeConfig
,app
,build
,buildModules
,alias
,modules
- Runtime Modules:
-
- Build Modules:
@pinia/nuxt@0.4.1
Reproduction
// package.json { “private”: true, “scripts”: { “build”: “nuxt build”, “dev”: “nuxt dev”, “generate”: “nuxt generate”, “generate:dev”: “nuxt generate”, “preview”: “nuxt preview”, “lint”: “eslint --ext .js,.vue,.ts --ignore-path .gitignore .”, “lintfix”: “eslint --fix --ext .js,.vue,.ts --ignore-path .gitignore .”, “precommit”: “npm run lint” }, “devDependencies”: { “@nuxtjs/eslint-config-typescript”: “^10.0.0”, “@nuxtjs/proxy”: “^2.1.0”, “@typescript-eslint/eslint-plugin”: “^5.35.1”, “@typescript-eslint/parser”: “^5.35.1”, “ali-oss”: “^6.17.1”, “co”: “^4.6.0”, “eslint”: “^8.23.0”, “eslint-plugin-vue”: “^9.4.0”, “gulp”: “^4.0.2”, “less-loader”: “^11.0.0”, “nuxt”: “3.0.0-rc.8”, “path”: “^0.12.7”, “through2”: “^4.0.2”, “typescript”: “^4.8.2”, “vue-tsc”: “^0.40.1” }, “dependencies”: { “@nuxt/webpack-builder”: “^3.0.0-rc.8”, “@pinia/nuxt”: “^0.4.1”, “less”: “^4.1.3”, “normalize.css”: “^8.0.1”, “pinia”: “^2.0.21”, “vue-lazyload”: “^3.0.0-rc.2”, “vuex”: “^4.0.2” } }
// nuxt.config.ts import { defineNuxtConfig } from ‘nuxt’
const isProduction = process.env.NODE_ENV === ‘production’ const cdnUrl = ‘xxxxxxx’
let config = defineNuxtConfig({ css: [ ‘assets/styles/base.less’, ‘assets/styles/main.less’ ], runtimeConfig: { public: { cdnUrl: isProduction ? cdnUrl : ‘/’ } }, app: { head: { script: [ { src: ‘/script/changeRootFontSize.js’, async: true } ], meta: [ { charset: ‘utf-8’ }, { name: ‘viewport’, content: ‘width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0,viewport-fit=cover’ }, { name: ‘apple-mobile-web-app-capable’, content: ‘yes’ }, { name: ‘full-screen’, content: ‘true’ }, { name: ‘x5-fullscreen’, content: ‘true’ }, { name: ‘360-fullscreen’, content: ‘true’ } ] } }, build: { transpile: [] }, buildModules: [‘@pinia/nuxt’], alias: { ‘@vue/devtools-api’: ‘@vue/devtools-api’ }, modules: [] })
// error
export default config
Describe the bug
It was no problem to run on the window yesterday, but today I changed the mac and reported this error directly
Additional context
No response
Logs
No response
Issue Analytics
- State:
- Created a year ago
- Comments:6 (4 by maintainers)
Top GitHub Comments
Having said that, from the screenshot, it looks like you have run Nuxt 2 at some point in this project. Would you remove your
.nuxt
folder and retry?No problem - glad to find the issue!