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.

When running `nuxt/content` in RC 10 I get a server error

See original GitHub issue

Environment


  • Operating System: Darwin
  • Node Version: v16.17.0
  • Nuxt Version: 3.0.0-rc.10
  • Nitro Version: 0.5.3
  • Package Manager: npm@8.15.0
  • Builder: vite
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

I sadly cannot provide a reproduction link, as the project is internal. However here is my package.json:

{
  "private": true,
  "engines": {
    "node": ">=16.14.2",
    "npm": ">=8.5.0"
  },
  "scripts": {
    "dev": "nuxi dev",
    "build": "nuxi build",
    "start": "NODE_ENV=production node .output/server/index.mjs",
    "lint": "npm-run-all lint:*",
    "lint:types": "nuxi typecheck",
    "lint:style": "eslint .",
    "test": "npm-run-all postinstall && TZ=UTC vitest --run",
    "test:watch": "npm-run-all postinstall && TZ=UTC vitest",
    "test:ui": "npm-run-all postinstall && TZ=UTC vitest --ui",
    "prepare": "husky install",
    "postinstall": "nuxi prepare",
    "story": "histoire dev",
    "story:build": "histoire build",
    "generate": "nuxi generate && rm -rf docs && mv .output/public docs && touch docs/.nojekyll && cp CNAME docs/"
  },
  "dependencies": {
    "@fortawesome/fontawesome-free": "^6.2.0",
    "@sidestream-tech/nuxt-sidebase-parse": "^0.2.6",
    "@vueuse/core": "^9.2.0",
    "aos": "^2.3.4",
    "sqlite3": "^5.1.1",
    "typeorm": "^0.3.9"
  },
  "devDependencies": {
    "@antfu/eslint-config-vue": "^0.26.3",
    "@babel/core": "^7.18.2",
    "@faker-js/faker": "^7.5.0",
    "@histoire/plugin-nuxt": "^0.10.7",
    "@histoire/plugin-vue": "^0.10.7",
    "@nuxt/content": "^2.1.1",
    "@nuxtjs/tailwindcss": "^5.3.2",
    "@testing-library/jest-dom": "^5.16.5",
    "@testing-library/vue": "^6.6.1",
    "@types/aos": "^3.0.4",
    "@types/node": "^18.7.18",
    "@types/supertest": "^2.0.12",
    "@typescript-eslint/eslint-plugin": "^5.36.1",
    "@typescript-eslint/parser": "^5.36.1",
    "@vitejs/plugin-vue": "^3.0.3",
    "@vitest/coverage-c8": "^0.23.2",
    "@vitest/ui": "^0.23.2",
    "ant-design-vue": "^3.2.12",
    "babel-loader": "^8.2.4",
    "eslint": "^8.23.0",
    "eslint-plugin-tailwindcss": "^3.6.2",
    "eslint-plugin-vue": "^9.4.0",
    "histoire": "^0.10.7",
    "husky": "^8.0.1",
    "jsdom": "^20.0.0",
    "lint-staged": "^13.0.1",
    "npm-run-all": "^4.1.5",
    "nuxt": "^3.0.0-rc.10",
    "sass": "^1.54.9",
    "supertest": "^6.2.4",
    "unplugin-auto-import": "^0.11.2",
    "unplugin-vue-components": "^0.22.4",
    "vite-plugin-eslint": "^1.8.1",
    "vite-svg-loader": "^3.5.1",
    "vitest": "^0.23.2",
    "vue": "^3.2.38",
    "vue-loader": "^17.0.0",
    "vue-tsc": "^0.40.9"
  },
  "lint-staged": {
    "*{.js,.ts,.vue}": "eslint --fix ."
  }
}

And my Nuxt Config:

import { isProduction } from './helpers'

// Needed to keep `ant-design-vue` running as of latest RC.8, see https://github.com/nuxt/framework/issues/6941#issuecomment-1229739856
const transpile = ['lodash-es']
if (isProduction) {
  // For production build via rollup, we need to also transpile babel
  transpile.push('@babel/runtime')
}

// https://v3.nuxtjs.org/docs/directory-structure/nuxt.config
export default defineNuxtConfig({
  // Needed to keep `ant-design-vue` running as of latest RC.8, see https://github.com/nuxt/framework/issues/6941#issuecomment-1229739856
  alias: {
    dayjs: 'dayjs/esm/',
  },
  css: ['/assets/style.css', '@fortawesome/fontawesome-free/css/all.min.css', 'aos/dist/aos.css'],
  typescript: {
    // We enable `Volar Takeover Mode`, so we can disable the shim `*.vue` generation
    // see https://v3.nuxtjs.org/getting-started/introduction#prerequisites
    shim: false,
    strict: true,
  },
  build: {
    transpile,
  },
  modules: ['@nuxt/content', '@nuxtjs/tailwindcss'],
})

Describe the bug

After adding nuxt/content to my project and including it in the nuxt.config.ts file I get the following error when starting the project with npm run dev.

 ERROR  [worker reload] [worker init] Named export 'postprocess' not found. The requested module 'file:///node_modules/micromark/lib/postprocess.js' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'file:///node_modules/micromark/lib/postprocess.js';
const { postprocess } = pkg;


  import { postprocess } from 'node_modules/micromark/lib/postprocess.js';
  ^^^^^^^^^^^
  SyntaxError: Named export 'postprocess' not found. The requested module 'node_modules/micromark/lib/postprocess.js' is a CommonJS module, which may not support all module.exports as named exports.
  CommonJS modules can always be imported via the default export, for example using:
  
  import pkg from 'node_modules/micromark/lib/postprocess.js';
  const { postprocess } = pkg;
  
  at ModuleJob._instantiate (node:internal/modules/esm/module_job:123:21)
  at async ModuleJob.run (node:internal/modules/esm/module_job:189:5)
  at async Promise.all (index 0)
  at async ESMLoader.import (node:internal/modules/esm/loader:533:24)
  at async loadESM (node:internal/process/esm_loader:91:5)
  at async handleMainPromise (node:internal/modules/run_main:65:12)

Additional context

No response

Logs

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:3
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
farnabazcommented, Oct 18, 2022

Have your tried to clean install dependencies by removing yarn.lock/package-lock.json?

This is likely happening because of conflict in micromark version. I’ve tried to create simple project with your dependencies and nuxt.config, everything works fine.

2reactions
zoey-kaisercommented, Sep 28, 2022

I was doing some more investigation and saw that the package @antfu/eslint-config-vue also used micromark, however a older version. After removing the package to ensure only the new version is used I received a new error message:

Nuxi 3.0.0-rc.10                                                                                                                                                                                                          14:04:36
Nuxt 3.0.0-rc.10 with Nitro 0.5.3                                                                                                                                                                                         14:04:36
                                                                                                                                                                                                                          14:04:37
  > Local:    http://localhost:3000/ 
  > Network:  http://192.168.0.130:3000/

ℹ Please create ~/components/content and restart the Nuxt server to use components in Markdown                                                                                                              @nuxt/content 14:04:37
ℹ Using default Tailwind CSS file from runtime/tailwind.css                                                                                                                                              nuxt:tailwindcss 14:04:37
ℹ Tailwind Viewer: http://localhost:3000/_tailwind/                                                                                                                                                      nuxt:tailwindcss 14:04:38

 WARN  'micromark/lib/preprocess.js' is imported by node_modules/@nuxt/content/dist/runtime/transformers/csv/from-csv.mjs, but could not be resolved – treating it as an external dependency                              14:04:41


 WARN  'micromark/lib/postprocess.js' is imported by node_modules/@nuxt/content/dist/runtime/transformers/csv/from-csv.mjs, but could not be resolved – treating it as an external dependency                             14:04:41

ℹ Vite client warmed up in 3432ms                                                                                                                                                                                         14:04:42

 WARN  'unist-util-stringify-position' is imported by node_modules/@nuxt/content/dist/runtime/transformers/csv/from-csv.mjs, but could not be resolved – treating it as an external dependency                            14:04:42


 WARN  'mdast-util-to-string' is imported by node_modules/@nuxt/content/dist/runtime/transformers/csv/from-csv.mjs, but could not be resolved – treating it as an external dependency                                     14:04:43

✔ Nitro built in 2676 ms                                                                                                                                                                                            nitro 14:04:43

 ERROR  [worker reload] [worker init] Cannot find package 'mdast-util-to-string' imported from .nuxt/dev/index.mjs                                          14:04:43

  at new NodeError (node:internal/errors:387:5)
  at packageResolve (node:internal/modules/esm/resolve:951:9)
  at moduleResolve (node:internal/modules/esm/resolve:1000:20)
  at defaultResolve (node:internal/modules/esm/resolve:1214:11)
  at nextResolve (node:internal/modules/esm/loader:165:28)
  at ESMLoader.resolve (node:internal/modules/esm/loader:844:30)
  at ESMLoader.getModuleJob (node:internal/modules/esm/loader:431:18)
  at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:40)
  at link (node:internal/modules/esm/module_job:75:36)
Read more comments on GitHub >

github_iconTop Results From Across the Web

v3.0.0-rc.10 · Discussion #7513 · nuxt/framework - GitHub
Im getting this error when building: ✓ Server built in 23430ms 22:01:33 ✓ Generated public .output/public nitro 22:01:33 ℹ Initializing prerenderer nitro ...
Read more >
Nuxt 3 impossible to run dev - Stack Overflow
For some reason i cannot start a nuxt project. you can find the error message i get when i do an "npm run...
Read more >
Announcing Nuxt 3 Release Candidate
Nuxt 3 beta was announced on October 12, 2021 after 16 months of work, introducing a new foundation based on Vue 3, Vite...
Read more >
@nuxtjs/apollo - npm
Start using @nuxtjs/apollo in your project by running `npm i @nuxtjs/apollo`. There are 23 other projects in the npm registry using ...
Read more >
Dependencies | nuxt | npm - Open Source Insights
arrow_right @nuxt/babel‑preset‑app. 2.15.7 Notes Relation Licenses Version 2.15.7 Published June 14, 2021 Description arrow_right @nuxt/builder. 2.15.7 Notes Relation Licenses Version 2.15.7 Published June 14, 2021
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