Skip to content

Cannot find module './cjs/react.development.js' #624

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

Open
conico974 opened this issue Nov 8, 2024 · 3 comments
Open

Cannot find module './cjs/react.development.js' #624

conico974 opened this issue Nov 8, 2024 · 3 comments

Comments

@conico974
Copy link
Contributor

When doing function splitting with only app router component on lambda, this issue can happen.
This file is included for every app router route/component, including _app and _document, which are bundled everywhere except on app router only splitted function. (it should not be included btw)

The import is done before the setNodeEnv function call on lambda and so NODE_ENV is undefined and react try to load the dev stuff.

FIX

There is a very easy fix for those running into this set the NODE_ENV env variable to production.
This should also be done on sst by default

@asynchroza
Copy link

I'm using SST which calls open-next under the hood but it seems I cannot propagate the environment variable even when using cross-env. Do you have any clue what the issue here might be?

@sommeeeer
Copy link
Contributor

I'm using SST which calls open-next under the hood but it seems I cannot propagate the environment variable even when using cross-env. Do you have any clue what the issue here might be?

whats in your sst.aws.Nextjs and are you using splitted server functions?

@asynchroza
Copy link

I'm using SST which calls open-next under the hood but it seems I cannot propagate the environment variable even when using cross-env. Do you have any clue what the issue here might be?

whats in your sst.aws.Nextjs and are you using splitted server functions?

For anybody else who is using SST, after some discussions with the team @sommeeeer and @conico974, I got it running by updating my sst configuration as follows:

// eslint-disable-next-line @typescript-eslint/triple-slash-reference
/// <reference path="./.sst/platform/config.d.ts" />

export default $config({
    app(input) {
        return {
            name: 'pronto',
            removal: input?.stage === 'production' ? 'retain' : 'remove',
            protect: ['production'].includes(input?.stage),
            home: 'aws',
        };
    },
    async run() {
        new sst.aws.Nextjs('Core', {
            environment: {
                // ! @link https://github.com/opennextjs/opennextjs-aws/issues/624
                // TODO: Look into moving to a newer version when this is merged @link https://github.com/opennextjs/opennextjs-aws/pull/800
                NODE_ENV: 'production',
            },
        });
    },
}

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