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

nuxi build -> ERROR Rollup error: Unexpected token #1211

Closed
fanckush opened this issue Jun 4, 2022 · 6 comments · Fixed by #1239
Closed

nuxi build -> ERROR Rollup error: Unexpected token #1211

fanckush opened this issue Jun 4, 2022 · 6 comments · Fixed by #1239

Comments

@fanckush
Copy link

fanckush commented Jun 4, 2022

Environment


  • Operating System: Darwin
  • Node Version: v17.3.1
  • Nuxt Version: 3.0.0-rc.3-27571095.9379606
  • Package Manager: [email protected]
  • Builder: vite
  • User Config: extends, buildModules, build, ssr
  • Runtime Modules: -
  • Build Modules: @nuxt/[email protected]

Reproduction

I've started incorporating nuxt/modules into my nuxt3 project. I am unable to build (SSR false or true) I get the following error

$ nuxi build
Nuxt CLI v3.0.0-rc.3-27571095.9379606                                                                                                        17:44:38
✔ Using ~/components/content for components in Markdown                                                                        @nuxt/content 17:44:39
ℹ Vite client warmed up in 789ms                                                                                                             17:44:41
ℹ Client built in 2677ms                                                                                                                     17:44:43
ℹ Building server...                                                                                                                         17:44:43
✔ Server built in 1068ms                                                                                                                     17:44:44
✔ Generated public .output/public                                                                                                      nitro 17:44:44
ℹ Initializing prerenderer                                                                                                             nitro 17:44:44
ℹ Prerendering 4 routes                                                                                                                nitro 17:44:45
  ├─ / (8ms)                                                                                                                           nitro 17:44:45
  ├─ /200 (1ms)                                                                                                                        nitro 17:44:45
  ├─ /404 (0ms)                                                                                                                        nitro 17:44:45
  ├─ /api/_content/cache (149ms)                                                                                                       nitro 17:44:46
start Building server...                                                                                                               nitro 17:44:46

 ERROR  Rollup error: Unexpected token (Note that you need plugins to import files that are not JavaScript)                            nitro 17:44:46


 ERROR  Unexpected token (Note that you need plugins to import files that are not JavaScript)                                                17:44:46

  at error (node_modules/rollup/dist/es/shared/rollup.js:1840:30)
  at Module.error (node_modules/rollup/dist/es/shared/rollup.js:12528:16)
  at Module.tryParse (node_modules/rollup/dist/es/shared/rollup.js:12905:25)
  at Module.setSource (node_modules/rollup/dist/es/shared/rollup.js:12810:24)
  at ModuleLoader.addModuleSource (node_modules/rollup/dist/es/shared/rollup.js:22284:20)

error Command failed with exit code 1.

Describe the bug

if I comment out the following line in nuxt.config file then I'm able the error is gone

import { defineNuxtConfig } from 'nuxt'

export default defineNuxtConfig({
  modules: ['@nuxt/content'], // commenting out this line fixes the issue
  })

Additional context

No response

Logs

No response

@atinux
Copy link
Member

atinux commented Jun 4, 2022

This may comme from one of your Markdown files, can you try to remove them and add them one by one by and building to see which one is causing it?

@fanckush
Copy link
Author

fanckush commented Jun 5, 2022

@atinux spot on! one Markdown file contained a ' in its name. Example:

~/content/i'm-a-test.md    ---> breaks
~/content/im-a-test.md     ---> works

removing the apostrophe fixed the issue. Maybe the error needs to be more clear or maybe ' should be allowed in the file name?

Copy link
Member

atinux commented Jun 9, 2022

Well I think using ' is definetely not a best practice for filenames. Maybe we could find a way to warn this to improve the DX @farnabaz ?

@farnabaz
Copy link
Member

farnabaz commented Jun 9, 2022

We can warn and ignore these files inside getContentIds.

@shiftlabs1
Copy link

@atinux i get this same error but in my case, I am not using markdown. It however shows up when i use genQL (https://genql.vercel.app/) within the server/api directory. when I comment the reference to the genQL client , the error goes away

Copy link
Member

atinux commented Jul 11, 2022

Have you tried to use https://github.com/diizzayy/nuxt-graphql-client instead @shiftlabs1 ?

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

Successfully merging a pull request may close this issue.

4 participants