Cannot find module './cjs/react.development.js'
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
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?
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?
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.Nextjsand 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',
},
});
},
}
Fixed in https://github.com/opennextjs/opennextjs-aws/pull/800