Trying to deploying a next.js project from my local machine to a Ubuntu server on digital ocean. When running the next build on the server I get the following web pack error. But I don't have any issues when building locally. When looking into this is sounded like a node issue but I haven't been able determine the issue after trying a few versions of node.
(node:10557) UnhandledPromiseRejectionWarning: Error: Cannot find module 'webpack'
Require stack:
- /home/commonsadmin/commons-web-frontend/node_modules/@next/react-refresh-utils/ReactRefreshWebpackPlugin.js
- /home/commonsadmin/commons-web-frontend/node_modules/next/dist/build/webpack-config.js
- /home/commonsadmin/commons-web-frontend/node_modules/next/dist/build/index.js
- /home/commonsadmin/commons-web-frontend/node_modules/next/dist/cli/next-build.js
- /home/commonsadmin/commons-web-frontend/node_modules/next/dist/bin/next
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/home/commonsadmin/commons-web-frontend/node_modules/@next/react-refresh-utils/ReactRefreshWebpackPlugin.js:3:19)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:10557) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:10557) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Local Info node: v15.1.0 os: macOS 11.1
Server Info node: v15.1.0 os: Ubuntu 20.08
my package.json
{
"name": "commons-frontend",
"version": "1.0.0",
"description": "A social reading space at a different pace of conversation.",
"main": "index.js",
"scripts": {
"dev": "next",
"build": "next build",
"start": "next start"
},
"keywords": [
],
"author": "tbd",
"license": "ISC",
"dependencies": {
"i": "^0.3.6",
"isomorphic-fetch": "^3.0.0",
"js-cookie": "^2.2.1",
"jsonwebtoken": "^8.5.1",
"moment": "^2.24.0",
"next": "^10.0.5",
"npm": "^6.11.3",
"nprogress": "^0.2.0",
"prop-types": "^15.7.2",
"query-string": "^6.8.3",
"react": "^16.9.0",
"react-dom": "^16.9.0",
"react-google-login": "^5.0.5",
"react-quill": "^1.3.3",
"react-render-html": "^0.6.0",
"reactstrap": "^8.0.1",
"sass": "^1.32.4"
}
}