question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SyntaxError: Unexpected token 'export'

See original GitHub issue

Environment

  • Operating System: Windows_NT
  • Node Version: v14.18.0
  • Nuxt Version: 3-3.0.0-27234503.d5127e9
  • Package Manager: Yarn
  • Bundler: Webpack
  • User Config: build
  • Runtime Modules: -
  • Build Modules: -

Describe the bug

image

When i install Element Plus it’s the error that i see

Reproduction

https://github.com/marckent04/nuxt3-first-app/tree/frontend

Additional context

No response

Logs

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
wobsorianocommented, Oct 14, 2021

I’m currently creating a nuxt plugin and got the same error. To fix it I added it to the list of deps prevented from being externalized for SSR.

import {
  defineNuxtModule,
  addPlugin,
  extendViteConfig
} from '@nuxt/kit';
import { resolve } from 'path';

export default defineNuxtModule({
  name: 'nuxt3-module',
  configKey: 'options',
  setup(options) {
    addPlugin({
      src: resolve(__dirname, './plugin.mjs')
    });

    extendViteConfig((config) => {
      // @ts-expect-error: vite
      config.ssr = {
        noExternal: [
          'some-module',
        ]
      };
    });
  }
});
1reaction
danielroecommented, Nov 4, 2021

@productdevbook You might need also to transpile the packages that are being imported by the package you’ve added to transpile. I’ve created a PR to help expose which packages they are: #1696.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting Unexpected Token Export - javascript - Stack Overflow
The problem was that I was changing my code from non-modules to modules and I forgot to delete the imported script file. My...
Read more >
SyntaxError: Unexpected token 'export' in JavaScript
To solve the "Uncaught SyntaxError Unexpected token 'export'" error, set the type property to module in your package.json file.
Read more >
How to fix SyntaxError: Unexpected token 'export' in JavaScript?
In this article, we are going to see How to fix SyntaxError: Unexpected token 'export' in JavaScript? and what are Es6 modules.
Read more >
How to Solve Unexpected Token 'export' Error in JavaScript
To solve the "Uncaught SyntaxError Unexpected token 'export'" error, set the type property to module in your package.json file.
Read more >
SyntaxError: Unexpected token 'export' - Abhishek Kumar
In case you are getting error like 'Unexpected token export' while starting the server, then export like below in schema.js
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found