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

Bug: node_modules not bundled with open next build when using npm monorepo/workspaces #1308

Open
jacksors opened this issue Oct 18, 2024 · 2 comments
Assignees

Comments

@jacksors
Copy link

jacksors commented Oct 18, 2024

When deploying an opennext app that's inside of an npm monorepo using workspaces, a node_modules folder is not bundled in the open next server_functions folder as it is when building a nextjs app with open next outside of a monorepo (when there is a node_modules folder inside the nextjs root).

For instance, if we have a nextjs app located at applications/nextjs, and we run sst deploy from the monorepo root where the root package.json and sst.config.ts is located, the built app will not have any dependencies included and will not be able to run.

@jacksors jacksors changed the title node_modules not bundled with open next build when using npm monorepo node_modules not bundled with open next build when using npm monorepo/workspaces Oct 18, 2024
@jacksors jacksors changed the title node_modules not bundled with open next build when using npm monorepo/workspaces Bug: node_modules not bundled with open next build when using npm monorepo/workspaces Oct 18, 2024
@jayair
Copy link
Contributor

jayair commented Oct 18, 2024

I haven't tried it recently but usually it only bundles that directory if you have dependencies in the nodejs.install. Do you have something like that? Can I see your sst config for the Next.js site?

@jacksors
Copy link
Author

I'm not sure what you mean by in the nodejs.install, could you clarify? Like global packages? Here's my config:

import { vpc } from "./vpc";
import {
  betterAuthSecret,
  googleClientId,
  googleClientSecret,
  queueApiKey,
  WEB_URL,
} from "./secrets";
import { appDb } from "./app-db";
import { bullmqPrimary } from "./bullmq";
import { devEmail, email, emailTemplate } from "./messaging";

export const web = new sst.aws.Nextjs("Web", {
  vpc,
  path: "applications/web/",
  dev: {
    url: "http://localhost:3000",
  },
  link: [
    appDb,
    googleClientId,
    googleClientSecret,
    queueApiKey,
    betterAuthSecret,
    bullmqPrimary,
    emailTemplate,
    email ? email : [],
    devEmail ? devEmail : [],
  ],
  environment: { WEB_URL },
});

The workaround I'm currently using is just removing applications/web/ from my root package.json so the nextjs app's dependencies are handled separately from the rest of the monorepo's, but this breaks the automated deployment on the SST cosole since that only installs packages in the root directory.

Thanks for taking a look at this!

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

No branches or pull requests

3 participants