next.js error: Error: > Build failed because of webpack errors - node.js

I'm trying to deploy a nextJs app but when I run npm run build I see some of the errors listed below:
Build error occurred
Error:
Build failed because of webpack errors
at /Users/hassan/Upwork/ROCProjectNext.js/ROCNext/node_modules/next/dist/build/index.js:15:918
at runMicrotasks ()
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async /Users/hassan/Upwork/ROC Project Next.js/ROC- Next/node_modules/next/dist/build/tracer.js:1:525
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! admin-1.0#0.1.0 build: next build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the admin-1.0#0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely
additional logging output above.
npm ERR! A complete log of this run can be found in: npm ERR!
/Users/hassan/.npm/_logs/2021-04-07T06_52_28_325Z-debug.log
any suggestions?

Kindly check your nextjs version in package.json file it is upgraded to latest version. Downgrade the version of nextjs it will help you to avoid this error.

Related

NPM run dev error after requiring Tailwind CSS

I'm just dipping my toes into using Laravel for the first time, and I've had many issues so far. I've figured them out myself so far, but this one is driving me crazy!
After adding the line require('tailwindcss') in my webpack.mix.js file, I keep getting the following error when I run.
npm run dev
✖ Mix
Compiled with some errors in 452.52ms
ERROR in ./resources/css/app.css
Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
ModuleBuildError: Module build failed (from ./node_modules/postcss-loader/dist/cjs.js):
TypeError: Cannot read property 'config' of undefined
at getTailwindConfig (/home/timothy/blog/node_modules/tailwindcss/lib/lib/setupTrackingContext.js:81:62)
at /home/timothy/blog/node_modules/tailwindcss/lib/lib/setupTrackingContext.js:124:92
at /home/timothy/blog/node_modules/tailwindcss/lib/processTailwindFeatures.js:41:11
at plugins (/home/timothy/blog/node_modules/tailwindcss/lib/index.js:20:104)
at LazyResult.runOnRoot (/home/timothy/blog/node_modules/postcss/lib/lazy-result.js:339:16)
at LazyResult.runAsync (/home/timothy/blog/node_modules/postcss/lib/lazy-result.js:393:26)
at LazyResult.async (/home/timothy/blog/node_modules/postcss/lib/lazy-result.js:221:30)
at LazyResult.then (/home/timothy/blog/node_modules/postcss/lib/lazy-result.js:206:17)
at processResult (/home/timothy/blog/node_modules/webpack/lib/NormalModule.js:751:19)
at /home/timothy/blog/node_modules/webpack/lib/NormalModule.js:853:5
at /home/timothy/blog/node_modules/loader-runner/lib/LoaderRunner.js:399:11
at /home/timothy/blog/node_modules/loader-runner/lib/LoaderRunner.js:251:18
at context.callback (/home/timothy/blog/node_modules/loader-runner/lib/LoaderRunner.js:124:13)
at Object.loader (/home/timothy/blog/node_modules/postcss-loader/dist/index.js:142:7)
1 ERROR in child compilations (Use 'stats.children: true' resp. '--stats-children' for more details)
webpack compiled with 2 errors
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! # development: `mix`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the # development script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/timothy/.npm/_logs/2022-01-18T04_24_37_451Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! # dev: `npm run development`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the # dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/timothy/.npm/_logs/2022-01-18T04_24_37_460Z-debug.log
I've looked into my version of Node.js and PostCSS being an issue, as my version of node.js has been an issue that caused other problems I've had so far, but those two seem fine. If it matters, this is a Laravel project created with Composer on Ubuntu 20.04 with Laravel installer 4.2.9.
Just run this comman. Tailwind config file is missing.
npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init

Problem starting Electron app - [603:0827/215406.435140:FATAL:electron_main_delegate.cc(264)] Running as root without --no-sandbox is not supported

I am trying to set up a electron project. I have followed this tutorial and the previous ones.
But when I get to "Running your App" and type npm start, I get the following message:
myApp#1.0.0 start ***PATH***
electron .
[603:0827/215406.435140:FATAL:electron_main_delegate.cc(264)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.
***PATH***/node_modules/electron/dist/electron exited with signal SIGTRAP
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! myApp#1.0.0 start: `electron .`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the myApp#1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/tobias/.npm/_logs/2020-08-27T11_54_06_541Z-debug.log
npm version: 6.14.6
node.js version: 12.18.3
I'm using the WSL terminal in Visual Studio code.
I have tried installing the electron-quick-start package with the same outcome.
I don't know if it helps but in your package.json try changing the start script into
"start": "electron --no-sandbox ."

Next JS Cannot resolve fs when running npm run build

I have created a web application using Next JS which runs fine with npm run dev. But when I tried to run it in production mode with npm run build, I get the errors given below. I have tried changing the permissions of node_modules directory, running npm install, trying to update NodeJS and NPM however nothing works. I could not find much about this on the internet as well.
> html#0.1.0 build /var/www/app/html
> next build
Creating an optimized production build
Failed to compile.
./node_modules/mysql/lib/protocol/sequences/Query.js
Module not found: Can't resolve 'fs' in '/var/www/app/html/node_modules/mysql/lib/protocol/sequences'
> Build error occurred
Error: > Build failed because of webpack errors
at build (/var/www/app/html/node_modules/next/dist/build/index.js:13:917)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! html#0.1.0 build: `next build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the html#0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-08-14T04_54_38_531Z-debug.log
I have finally found the solution and my problem has been fixed. This error was showing up because there were some serverless-mysql DB files in the pages directory and the error disappeared after I moved those non-page files outside of the pages directory.
Source: https://github.com/vercel/next.js/issues/9768#issuecomment-663835978

Hyperleger Indy - TheOrgBook Module Build Failure due to Node and NPM Issue

I have deployed VON Network and Permitify Modules of Hyperledger Indy SSI VC Demo in MacOS successfully. I am facing issues in TheOrgBook setup. However TheOrgBook Demo is failing even after trying the hot fix suggested in the GitHub Issue #26.
ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/opt/app-root/src/src'
ERROR in Error: Error encountered resolving symbol values statically. Could not resolve localize-router relative to /opt/app-root/src/src/app/app.module.ts., resolving symbol AppModule in /opt/app-root/src/src/app/app.module.ts, resolving symbol AppModule in /opt/app-root/src/src/app/app.module.ts, resolving symbol AppModule in /opt/app-root/src/src/app/app.module.ts
npm ERR! code ELIFECYCLE
npm ERR! Failed at the tob-web#0.0.1 postinstall script 'ng build --prod --base-href ${NG_BASE_HREF:-/} ${NG_BUILD_FLAGS:-} && cp dist/themes/_active/index.html dist/index.html'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the tob-web package,
npm ERR! not with npm itself.
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs tob-web
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls tob-web
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /opt/app-root/src/npm-debug.log
Build failed
Wrong example, try this one link

Deploying Node and Angular to Heroku error

I'm trying to learn how to deploy a Node and Angular app to Heroku and am getting an error.
Here are the steps I'm taking
Create an empty repo on GitHub.
Deploy the pre-create project, which creates a new heroku app.
Next, I download and copy the code that is in the pre-created project.
Then I push that code up to the empty repo I created step 1.
I then go back to Heroku and manually deploy connecting my repo to it.
When deploying I get an error that I don't know how to resolve. This is strange to me since I have the pre-configured Heroku app along with the exact same code.
> Building dependencies
Installing node modules (package.json)
> mean-contactlist-angular2#0.0.0 postinstall /tmp/build_00959509bf83606e9586c85b4acd5130/worldofnick-LocalBeats-34154d74169daf6c8cdab1e9e5407bd4e4f9c24e
> ng build
Cannot read property 'config' of null
TypeError: Cannot read property 'config' of null
at Class.run (/tmp/build_00959509bf83606e9586c85b4acd5130/worldofnick-LocalBeats-34154d74169daf6c8cdab1e9e5407bd4e4f9c24e/node_modules/#angular/cli/tasks/build.js:16:56)
at Class.run (/tmp/build_00959509bf83606e9586c85b4acd5130/worldofnick-LocalBeats-34154d74169daf6c8cdab1e9e5407bd4e4f9c24e/node_modules/#angular/cli/commands/build.js:143:26)
at Class.<anonymous> (/tmp/build_00959509bf83606e9586c85b4acd5130/worldofnick-LocalBeats-34154d74169daf6c8cdab1e9e5407bd4e4f9c24e/node_modules/#angular/cli/ember-cli/lib/models/command.js:134:17)
at process._tickCallback (internal/process/next_tick.js:109:7)
npm ERR! Linux 3.13.0-133-generic
npm ERR! argv "/tmp/build_00959509bf83606e9586c85b4acd5130/worldofnick-LocalBeats-34154d74169daf6c8cdab1e9e5407bd4e4f9c24e/.heroku/node/bin/node" "/tmp/build_00959509bf83606e9586c85b4acd5130/worldofnick-LocalBeats-34154d74169daf6c8cdab1e9e5407bd4e4f9c24e/.heroku/node/bin/npm" "install" "--unsafe-perm" "--userconfig" "/tmp/build_00959509bf83606e9586c85b4acd5130/worldofnick-LocalBeats-34154d74169daf6c8cdab1e9e5407bd4e4f9c24e/.npmrc"
npm ERR! node v6.11.5
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! mean-contactlist-angular2#0.0.0 postinstall: `ng build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the mean-contactlist-angular2#0.0.0 postinstall script 'ng build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the mean-contactlist-angular2 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! ng build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs mean-contactlist-angular2
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls mean-contactlist-angular2
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /tmp/build_00959509bf83606e9586c85b4acd5130/worldofnick-LocalBeats-34154d74169daf6c8cdab1e9e5407bd4e4f9c24e/npm-debug.log
-----> Build failed
We're sorry this build is failing! You can troubleshoot common issues here:
https://devcenter.heroku.com/articles/troubleshooting-node-deploys
Some possible problems:
- Node version not specified in package.json
https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
Love,
Heroku
! Push rejected, failed to compile Node.js app.
! Push failed
I ran into this problem while deploying to Heroku today. In your package.json, make sure you are correctly specifying node as your engine. Example:
"engines": {
"node": "^8.0.0"
},

Resources