nuxt-modules / sanity

Sanity integration for Nuxt
https://sanity.nuxtjs.org
MIT License
211 stars 35 forks source link

Sanity dependencies must be installed when deploying to netlify. #999

Closed jmurphy-dev closed 2 months ago

jmurphy-dev commented 2 months ago

Version

module: "^1.11.3" nuxt: "^3.11.2"

Reproduction

Deploy to netlify with barebones nuxt and sanity setup.

What is expected?

The module says it can auto detect santy.config.ts

What is actually happening?

Netlify throws this error in the prepare stage.

12:27:44 PM: $ nuxt prepare
12:27:46 PM: Failed during stage 'Install dependencies': dependency_installation script returned non-zero exit code: 1
12:27:46 PM: [info] [nuxt:tailwindcss] Using default Tailwind CSS file
12:27:46 PM: [error] Cannot find module 'sanity'
12:27:46 PM: Require stack:
12:27:46 PM: - /opt/build/repo/cms/sanity.config.ts
12:27:46 PM:   Require stack:
12:27:46 PM:   - cms/sanity.config.ts
12:27:46 PM:   at Module._resolveFilename (node:internal/modules/cjs/loader:1140:15)
12:27:46 PM:   at Function.resolve (node:internal/modules/helpers:188:19)
12:27:46 PM:   at _resolve (node_modules/jiti/dist/jiti.js:1:251148)
12:27:46 PM:   at jiti (node_modules/jiti/dist/jiti.js:1:253746)
12:27:46 PM:   at cms/sanity.config.ts:1:177
12:27:46 PM:   at evalModule (node_modules/jiti/dist/jiti.js:1:256443)
12:27:46 PM:   at jiti (node_modules/jiti/dist/jiti.js:1:254371)
12:27:46 PM:   at setup (node_modules/@nuxtjs/sanity/dist/module.mjs:50:36)
12:27:46 PM:   at async normalizedModule (node_modules/@nuxt/kit/dist/index.mjs:2112:17)
12:27:46 PM:   at async installModule (node_modules/@nuxt/kit/dist/index.mjs:2415:95)
12:27:46 PM:   at async initNuxt (node_modules/nuxt/dist/index.mjs:4233:7)
12:27:46 PM:   at async loadNuxt (node_modules/nuxt/dist/index.mjs:4331:5)
12:27:46 PM:   at async loadNuxt (node_modules/@nuxt/kit/dist/index.mjs:2570:19)
12:27:46 PM:   at async Object.run (node_modules/nuxi/dist/chunks/prepare.mjs:53:18)
12:27:46 PM:   at async runCommand$1 (node_modules/nuxi/dist/shared/nuxi.9edf0930.mjs:1648:16)
12:27:46 PM:   at async runCommand$1 (node_modules/nuxi/dist/shared/nuxi.9edf0930.mjs:1639:11)
12:27:46 PM:   at async runMain$1 (node_modules/nuxi/dist/shared/nuxi.9edf0930.mjs:1777:7)
12:27:46 PM: [error] Cannot find module 'sanity'
12:27:46 PM: Require stack:
12:27:46 PM: - /opt/build/repo/cms/sanity.config.ts
12:27:46 PM: error: postinstall script from "nuxt-app" exited with 1

Steps to reproduce

Deploy a nuxt project with the sanity module resolving sanity.config.ts to netlify.

Additional information

Checklist

What is expected?

Nuxt sanity should not depend on the sanity dependencies being installed when deploy to netlify.

What is actually happening?

It seems like the when parsing the project information in sanity.config.ts the prepare script is throwing because the sanity dependencies arent installed.

danielroe commented 2 months ago

Nuxt depends on all your dependencies being installed when it builds. None of them will be included in the generated output, which is self contained. But if the Nuxt builder can't read your sanity.config then it can't get the Sanity project ID, which it needs to build your app.