nuxt / content

The file-based CMS for your Nuxt application, powered by Markdown and Vue components.
https://content.nuxt.com
MIT License
3.08k stars 624 forks source link

Possible bug with missing dependency when dependencies installed with `--omit=dev` #2630

Open remluben opened 4 months ago

remluben commented 4 months ago

Environment

- Operating System: Darwin
- Node Version:     v21.4.0
- Nuxt Version:     3.11.1
- CLI Version:      3.11.1
- Nitro Version:    2.9.5
- Package Manager:  npm@10.2.4
- Builder:          -
- User Config:      app, components, content, css, experimental, modules, i18n, imports, runtimeConfig, ssr, vite, devtools
- Runtime Modules:  floating-vue/nuxt, @nuxt/content@2.12.1, @nuxtjs/i18n@8.3.0, @pinia/nuxt@0.5.1, @pinia-plugin-persistedstate/nuxt@1.2.0
- Build Modules:    -

Reproduction

  1. Setup a nuxt project
  2. Make sure commands are correctly setup
    "scripts": {
    "dev": "nuxt",
    "build": "nuxt build",
    "start": "nuxt start",
    "generate": "nuxt generate"
    }
  3. Add @nuxt/content package in your nuxt project in dependencies (not dev) "@nuxt/content": "^2.12.1",
  4. Run npm i --omit=dev
  5. Run npm run dev or npm run build
  6. See an error similar to this: Cannot find package 'github-slugger' imported from /some/path/here/index.mjs

Describe the bug

When installinging dependencies without dev-dependencies using --omit=dev the @nuxt/content seems to miss dependencies to github-slugger.

Important note: If you install all dependencies (including dev) by using npm i everything works as expected.

Additional context

No response

Logs

ERROR  Cannot find package 'github-slugger' imported from /some/path/here/.nuxt/prerender/index.mjs                                         9:45:40 AM

  at packageResolve (node:internal/modules/esm/resolve:853:9)
  at moduleResolve (node:internal/modules/esm/resolve:910:20)
  at defaultResolve (node:internal/modules/esm/resolve:1130:11)
  at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:396:12)
  at ModuleLoader.resolve (node:internal/modules/esm/loader:365:25)
  at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:240:38)
  at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:85:39)
  at link (node:internal/modules/esm/module_job:84:36) 

 ERROR  Cannot find package 'github-slugger' imported from /some/path/here/.nuxt/prerender/index.mjs                                         9:45:40 AM
farnabaz commented 3 months ago

Did you use shamefully-hoist=true in .npmrc ? If not, try to add shamefully-hoist=true to .npmrc

remluben commented 3 months ago

Hi @farnabaz, many thanks for your feedback. ✌️

I will review our setup and give your suggestions a try asap.

I will let you know about my findings.

Kind regards, Benjamin