4lejandrito / next-plausible

Simple integration for https://nextjs.org and https://plausible.io analytics
https://next-plausible.vercel.app
MIT License
603 stars 33 forks source link

Cannot find package `.../node_modules/next-plausible/`, imported from `next.config.mjs` #117

Open ShubhamPalriwala opened 8 months ago

ShubhamPalriwala commented 8 months ago

Hey team, we're running into the below Build Error on Vercel:

[17:31:41.991] @formbricks/formbricks-com:build: > next build
[17:31:41.991] @formbricks/formbricks-com:build: 
[17:31:42.615] @formbricks/formbricks-com:build: - error Failed to load next.config.mjs, see more info here https://nextjs.org/docs/messages/next-config-error
[17:31:42.638] @formbricks/formbricks-com:build: 
[17:31:42.638] @formbricks/formbricks-com:build: > Build error occurred
[17:31:42.640] @formbricks/formbricks-com:build: Error [ERR_MODULE_NOT_FOUND]: Cannot find package '/vercel/path0/apps/formbricks-com/node_modules/next-plausible/' imported from /vercel/path0/apps/formbricks-com/next.config.mjs
[17:31:42.640] @formbricks/formbricks-com:build: Did you mean to import next-plausible/dist/index.js?
[17:31:42.640] @formbricks/formbricks-com:build:     at new NodeError (node:internal/errors:405:5)
[17:31:42.640] @formbricks/formbricks-com:build:     at legacyMainResolve (node:internal/modules/esm/resolve:234:9)
[17:31:42.640] @formbricks/formbricks-com:build:     at packageResolve (node:internal/modules/esm/resolve:877:14)
[17:31:42.640] @formbricks/formbricks-com:build:     at moduleResolve (node:internal/modules/esm/resolve:939:20)
[17:31:42.640] @formbricks/formbricks-com:build:     at defaultResolve (node:internal/modules/esm/resolve:1132:11)
[17:31:42.640] @formbricks/formbricks-com:build:     at nextResolve (node:internal/modules/esm/loader:163:28)
[17:31:42.640] @formbricks/formbricks-com:build:     at ESMLoader.resolve (node:internal/modules/esm/loader:835:30)
[17:31:42.640] @formbricks/formbricks-com:build:     at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
[17:31:42.640] @formbricks/formbricks-com:build:     at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:77:40)
[17:31:42.640] @formbricks/formbricks-com:build:     at link (node:internal/modules/esm/module_job:76:36) {
[17:31:42.641] @formbricks/formbricks-com:build:   code: 'ERR_MODULE_NOT_FOUND'
[17:31:42.641] @formbricks/formbricks-com:build: }
[17:31:42.649] @formbricks/formbricks-com:build:  ELIFECYCLE  Command failed with exit code 1.
[17:31:42.667] @formbricks/formbricks-com:build: ERROR: command finished with error: command (/vercel/path0/apps/formbricks-com) /pnpm8/node_modules/.bin/pnpm run build exited (1)
[17:31:42.667] @formbricks/formbricks-com#build: command (/vercel/path0/apps/formbricks-com) /pnpm8/node_modules/.bin/pnpm run build exited (1)
[17:31:42.671] 
[17:31:42.671]   Tasks:    3 successful, 4 total
[17:31:42.671]  Cached:    0 cached, 4 total
[17:31:42.671]    Time:    1m26.428s 
[17:31:42.671] Summary:    /vercel/path0/.turbo/runs/2dJW8WunFeXtkUU4pkY7PHjq86v.json
[17:31:42.671]  Failed:    @formbricks/formbricks-com#build
[17:31:42.671] 
[17:31:42.679]  ERROR  run failed: command  exited (1)
[17:31:42.809] Error: Command "cd ../.. && npx turbo run build --filter=formbricks-com..." exited with 1
[17:31:43.612] 

This only occurs on Vercel's fresh Production Builds, when Redeployed manually, it works! Eve locally, the build succeeds.

next.config.mjs (exact file is here: https://github.com/formbricks/formbricks/blob/main/apps/formbricks-com/next.config.mjs ):

import { withPlausibleProxy } from "next-plausible";
....
export default withPlausibleProxy({ customDomain: "https://plausible.formbricks.com" })(
  withSearch(withMDX(nextConfig))
);

Our versions are:

    "next": "13.4.19",
    "next-plausible": "^3.12.0",

And Node is 18

ShubhamPalriwala commented 8 months ago

hey team, any help on this?