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

Having production error - TypeError: (void 0) is not a function at .next/server/webpack-api-runtime.js:1:199 #2758

Open
5 tasks done
Likhitha4131 opened this issue Jul 16, 2024 · 1 comment

Comments

@Likhitha4131
Copy link

Describe the bug

I am using next.js having the production error
TypeError: (void 0) is not a function at .next/server/webpack-api-runtime.js:1:199
however if I am commenting out my module-federation code it seems to work fine
//next.config.js

`const NextFederationPlugin = require("@module-federation/nextjs-mf");

const nextConfig = {
reactStrictMode: false,
basePath: "/dc",
env: {
BASE_PATH: process.env.BASE_PATH
},
eslint: {
ignoreDuringBuilds: true
},
typescript: {
ignoreBuildErrors: true
},
webpack(config) {
const nextWebConfig = { ...config };
nextWebConfig.resolve.alias.canvas = false;
nextWebConfig.plugins.push(
new NextFederationPlugin({
name: "dc",
filename: "static/chunks/remoteEntry.js",
exposes: {
'./canned': './src/components/CannedRemoteEntry.tsx'
}
nextWebConfig.module.rules.push({
test: /@vtaits/use-lazy-ref/,
use: {
loader: 'babel-loader',
options: {
presets: ['next/babel'],
plugins: [
['@babel/plugin-transform-modules-commonjs', { 'allowTopLevelThis': true }]
]
}
}
},{
test: /.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['next/babel', '@babel/preset-env', '@babel/preset-react'],
}
}
});

return nextWebConfig;

},generateBuildId: async () => {
return "dc";
},
};

module.exports = nextConfig;`
//package.json
{
"name": "dc",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "cross-env NEXT_PRIVATE_LOCAL_WEBPACK=true node server.js",
"build": "next build",
"start": "NODE_ENV=production node server.js"
},
"dependencies": {
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.0",
"@mantine/core": "^7.7.1",
"@mantine/dates": "^7.7.1",
"@mantine/hooks": "^7.7.1",
"@material-ui/core": "^5.0.0-beta.5",
"@material-ui/icons": "^4.11.3",
"@module-federation/nextjs-mf": "8.2.0",
"@mui/icons-material": "^5.15.15",
"@mui/lab": "^5.0.0-alpha.170",
"@mui/material": "^5.15.14",
"@mui/x-data-grid": "^6.19.10",
"@mui/x-date-pickers": "^7.1.0",
"@mui/x-tree-view": "^7.3.0",
"@types/react-chartjs-2": "^2.5.7",
"axios": "^1.6.8",
"chart.js": "^4.4.2",
"chartjs": "^0.3.24",
"csurf": "^1.11.0",
"dayjs": "^1.11.10",
"env-cmd": "^10.1.0",
"express": "^4.19.2",
"html-webpack-plugin": "^5.6.0",
"moment": "^2.30.1",
"next": "14.1.4",
"next-auth": "^4.24.7",
"react": "^18.2.0",
"react-chartjs": "^1.2.0",
"react-chartjs-2": "^5.2.0",
"react-dom": "^18.2.0",
"react-select": "^5.8.0",
"react-select-async-paginate": "^0.7.4",
"sass": "^1.72.0",
"semver": "7.5.2"
},
"devDependencies": {
"@babel/core": "^7.24.5",
"@babel/plugin-transform-modules-commonjs": "^7.24.1",
"@babel/preset-env": "^7.24.5",
"@babel/preset-react": "^7.24.1",
"@babel/runtime": "^7.24.6",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"autoprefixer": "^10.0.1",
"babel-loader": "^9.1.3",
"babel-preset-es2015": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"cross-env": "^7.0.3",
"eslint": "^8n",
"eslint-config-next": "14.1.4",
"postcss": "^8",
"tailwindcss": "^3.3.0",
"typescript": "^5",
"webpack": "^5.90.0"
},
"resolutions": {
"semver": "7.5.2"
}
}

I am using yarn and my OS is mac .
It's working fine in my local and if I remove NODE_ENV='production' then also it's working fine
@ScriptedAlchemy , please look into this .

Reproduction

Can't share since it's confidentail companies project

Used Package Manager

yarn

System Info

//package.json
{
  "name": "dc",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "cross-env NEXT_PRIVATE_LOCAL_WEBPACK=true node server.js",
    "build": "next build",
    "start": "NODE_ENV=production node server.js"
  },
  "dependencies": {
    "@emotion/react": "^11.11.4",
    "@emotion/styled": "^11.11.0",
    "@mantine/core": "^7.7.1",
    "@mantine/dates": "^7.7.1",
    "@mantine/hooks": "^7.7.1",
    "@material-ui/core": "^5.0.0-beta.5",
    "@material-ui/icons": "^4.11.3",
    "@module-federation/nextjs-mf": "8.2.0",
    "@mui/icons-material": "^5.15.15",
    "@mui/lab": "^5.0.0-alpha.170",
    "@mui/material": "^5.15.14",
    "@mui/x-data-grid": "^6.19.10",
    "@mui/x-date-pickers": "^7.1.0",
    "@mui/x-tree-view": "^7.3.0",
    "@types/react-chartjs-2": "^2.5.7",
    "axios": "^1.6.8",
    "chart.js": "^4.4.2",
    "chartjs": "^0.3.24",
    "csurf": "^1.11.0",
    "dayjs": "^1.11.10",
    "env-cmd": "^10.1.0",
    "express": "^4.19.2",
    "html-webpack-plugin": "^5.6.0",
    "moment": "^2.30.1",
    "next": "14.1.4",
    "next-auth": "^4.24.7",
    "react": "^18.2.0",
    "react-chartjs": "^1.2.0",
    "react-chartjs-2": "^5.2.0",
    "react-dom": "^18.2.0",
    "react-select": "^5.8.0",
    "react-select-async-paginate": "^0.7.4",
    "sass": "^1.72.0",
    "semver": "7.5.2"
  },
  "devDependencies": {
    "@babel/core": "^7.24.5",
    "@babel/plugin-transform-modules-commonjs": "^7.24.1",
    "@babel/preset-env": "^7.24.5",
    "@babel/preset-react": "^7.24.1",
    "@babel/runtime": "^7.24.6",
    "@types/node": "^20",
    "@types/react": "^18",
    "@types/react-dom": "^18",
    "autoprefixer": "^10.0.1",
    "babel-loader": "^9.1.3",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-stage-0": "^6.24.1",
    "cross-env": "^7.0.3",
    "eslint": "^8n",
    "eslint-config-next": "14.1.4",
    "postcss": "^8",
    "tailwindcss": "^3.3.0",
    "typescript": "^5",
    "webpack": "^5.90.0"
  },
  "resolutions": {
    "semver": "7.5.2"
  }
}

Validations

@ScriptedAlchemy
Copy link
Member

can you supply a repo that recreates the issue

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

2 participants