WebPack module build error - node.js

Having trouble with building react project with WebPack.
Getting the following error output, is there a way to get a more info out of web pack on this issue.
running: webpack --display-error-details --display-reasons --progress -p --config webpack.config.prod.js
62% 478/543 build modulesError
at NormalModule.<anonymous> (...../node_modules/webpack/lib/NormalModule.js:113:20)
at NormalModule.onModuleBuild (..../node_modules/webpack-core/lib/NormalModuleMixin.js:310:10)
at nextLoader (..../node_modules/webpack-core/lib/NormalModuleMixin.js:275:25)
at ...node_modules/webpack-core/lib/NormalModuleMixin.js:259:5
at Storage.finished (....node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:38:16)
at .../node_modules/graceful-fs/graceful-fs.js:78:16
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:438:3)
69% 1917/1919 build modules

Related

Error [ERR_REQUIRE_ESM] in nuxtjs 2 while deploying with ec2

Getting error of Error [ERR_REQUIRE_ESM] while deploying nuxtjs 2 application.
Scripts:
"build": "nuxt build",
"start": "./node_modules/pm2/bin/pm2 start pm2.config.json"
Errors:
Error [ERR_REQUIRE_ESM]: require() of ES Module /var/app/current/node_modules/string-width/index.js from /var/app/current/node_modules/wrap-ansi/index.js not supported.
Instead change the require of /var/app/current/node_modules/string-width/index.js in /var/app/current/node_modules/wrap-ansi/index.js to a dynamic import() which is available in all CommonJS modules.
at Module.Hook._require.Module.require (/var/app/current/node_modules/require-in-the-middle/index.js:80:39)
at Object. (/var/app/current/node_modules/#nuxt/cli/dist/cli-index.js:15:18)
at Object. (/var/app/current/node_modules/nuxt/bin/nuxt.js:6:1)
at /var/app/current/node_modules/pm2/lib/ProcessContainer.js:303:25
at wrapper (/var/app/current/node_modules/async/internal/once.js:12:16)
at WriteStream. (/var/app/current/node_modules/pm2/lib/Utility.js:186:13)
at WriteStream.emit (node:events:527:28)
at FSReqCallback.oncomplete (node:fs:188:23)
EDIT:
AWS EC2 : upgrade from AMI 1 to AMI 2
Node: 16.15.1
Npm: 8.11.0

Problems with running Nuxt 3 [3.0.0-rc.3] on Apple silicon

I followed the quick guide to create an app using the operating system macOS Monterey 12.4 MacBook Pro M1 Max / Node v16.15.0 and also tried with 18.
When visiting the host http://localhost:3000, it repeats the error constantly [below shows the error in the terminal]. It looks like it could be a problem with the hot reload.
I tried reinstalling the node using brew and nvm for different node versions. This problem only curves on apple silicon, not on Intel-based machines. How can I solve this problem?
Creating nuxt app :
npx nuxi init nuxt-app
package.json :
{
"private": true,
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview"
},
"devDependencies": {
"nuxt": "3.0.0-rc.3"
}
}
After running npm run dev it through an error :
Nuxt CLI v3.0.0-rc.3 11:19:41
11:19:41
> Local: http://localhost:3000/
> Network: http://172.30.1.18:3000/
✘ [ERROR] Cannot read directory "../../..": operation not permitted
ERROR 11:19:43 AM [vite] error while updating dependencies: 11:19:43
Error: Build failed with 1 error:
error: Cannot read directory "../../..": operation not permitted
at failureErrorWithLog (/Users/USERNAME/nuxt-appnode_modules/esbuild/lib/main.js:1603:15)
at /Users/USERNAME/nuxt-appnode_modules/esbuild/lib/main.js:1249:28
at runOnEndCallbacks (/Users/USERNAME/nuxt-appnode_modules/esbuild/lib/main.js:1034:63)
at buildResponseToResult (/Users/USERNAME/nuxt-appnode_modules/esbuild/lib/main.js:1247:7)
at /Users/USERNAME/nuxt-appnode_modules/esbuild/lib/main.js:1356:14
at /Users/USERNAME/nuxt-appnode_modules/esbuild/lib/main.js:666:9
at handleIncomingPacket (/Users/USERNAME/nuxt-appnode_modules/esbuild/lib/main.js:763:9)
at Socket.readFromStdout (/Users/USERNAME/nuxt-appnode_modules/esbuild/lib/main.js:632:7)
at Socket.emit (node:events:527:28)
at Socket.emit (node:domain:475:12)
ERROR Vite Error, /_nuxt/node_modules/.vite/deps/vue.js?v=3f037d64 optimized info should be defined 11:19:43
ERROR Vite Error, /_nuxt/node_modules/.vite/deps/vue.js?v=3f037d64 optimized info should be defined 11:19:43
ERROR Vite Error, /_nuxt/node_modules/.vite/deps/vue.js?v=3f037d64 optimized info should be defined 11:19:43
ERROR Vite Error, /_nuxt/node_modules/.vite/deps/vue.js?v=3f037d64 optimized info should be defined 11:19:43
ERROR Vite Error, /_nuxt/node_modules/.vite/deps/vue.js?v=3f037d64 optimized info should be defined 11:19:43
ERROR Vite Error, /_nuxt/node_modules/.vite/deps/vue.js?v=3f037d64 optimized info should be defined 11:19:43
ERROR Vite Error, /_nuxt/node_modules/.vite/deps/vue.js?v=3f037d64 optimized info should be defined (repeated 20 times)
ERROR Vite Error, /_nuxt/node_modules/.vite/deps/ufo.js?v=2227049b optimized info should be defined 11:19:43
ERROR Vite Error, /_nuxt/node_modules/.vite/deps/ufo.js?v=2227049b optimized info should be defined 11:19:43
ERROR Vite Error, /_nuxt/node_modules/.vite/deps/ufo.js?v=2227049b optimized info should be defined 11:19:43
ERROR Vite Error, /_nuxt/node_modules/.vite/deps/ufo.js?v=2227049b optimized info should be defined 11:19:43
ERROR Vite Error, /_nuxt/node_modules/.vite/deps/ufo.js?v=2227049b optimized info should be defined 11:19:43
ERROR Vite Error, /_nuxt/node_modules/.vite/deps/ufo.js?v=2227049b optimized info should be defined 11:19:43
ERROR Vite Error, /_nuxt/node_modules/.vite/deps/vue.js?v=3f037d64 optimized info should be defined 11:19:43
ERROR Vite Error, /_nuxt/node_modules/.vite/deps/vue.js?v=3f037d64 optimized info should be defined 11:19:43
ℹ Vite server warmed up in 112ms 11:19:43
ℹ Vite client warmed up in 438ms 11:19:43
✔ Vite server built in 335ms 11:19:43
✔ Nitro built in 174 ms nitro 11:19:43
I have updated npm to 8.11.0, and no issue on M1 Max.
Vesrions I used:
Nuxt: 3.0.0-rc.3
Node: v16.15.0
Npm 8.11.0

React App failed to compile after install

After running the install script, the server starts and serves a page displaying the same text after the 'Failed to compile line.'
I'm running Windows 10 and auto update just updated my pc today, right before I did the create-react-express install.
PS H:\mern-passport> npm start
> mern#1.0.0 start H:\mern-passport
> if-env NODE_ENV=production && npm run start:prod || npm run start:dev
> mern#1.0.0 start:dev H:\mern-passport
> concurrently "nodemon --ignore 'client/*'" "npm run client"
[0] [nodemon] 1.19.4
[0] [nodemon] to restart at any time, enter `rs`
[0] [nodemon] watching dir(s): *.*
[0] [nodemon] watching extensions: js,mjs,json
[0] [nodemon] starting `node server.js`
[0] API server now on port 3001!
[1]
[1] > mern#1.0.0 client H:\mern-passport
[1] > cd client && npm run start
[1]
[1]
[1] > mern#0.1.0 start H:\mern-passport\client
[1] > react-scripts start
[1]
[1] Starting the development server...
[1]
[1] Failed to compile.
[1]
[1] ./src/index.css (./node_modules/css-loader??ref--6-oneOf-3-1!./node_modules/postcss-loader/src??postcss!./src/index.css)
[1] Error: Package exports for 'H:\mern-passport\client\node_modules\autoprefixer\node_modules\kleur' do not define a valid './colors' target
[0] Error: ENOENT: no such file or directory, stat 'H:\mern-passport\client\build\index.html'
[0] Error: ENOENT: no such file or directory, stat 'H:\mern-passport\client\build\index.html'
Seems to be an issue with autoprefixer latest version. I referred https://github.com/postcss/autoprefixer/issues/1328 and tried downgrading autoprefixer in my project and it works now.
Try:
npm install autoprefixer#9.8.0
Happy coding!
I also faced this problem. And it looks like a problem with autoprefixer version, so i changed the version.
npm install autoprefixer#9.8.0
I tried this, and it works perfectly.
I was running into this issue too. I installed yarn and created a new project with the npx create-react-app command and this fixed the issue.

node.js & react - server not up, from github project

I found one project on GitHub darkwire and wanted to install it and play with it. Firstly I tried to install it from windows. I installed Node.js and Yarn and I got errors with the command: yarn dev
`C:\darkwire.io-master>yarn dev
yarn run v1.21.1
$ concurrently 'cd client && yarn start' 'cd server && yarn dev'
[0] 'c' is not recognized as an internal or external command,
[0] operable program or batch file.
[1] 'client' is not recognized as an internal or external command,
[1] operable program or batch file.
[0] c exited with code 1
[1] client exited with code 1
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.`
My next step was to try it in ubuntu 19.10, firstly I installed again Node.js and Yarn and again used: yarn dev. I got an error but now was open site and it not working, just say "Disconnected"
```qq#ubuntu:~/Downloads/darkwire.io-master$ yarn dev
yarn run v1.21.1
$ concurrently 'cd client && yarn start' 'cd server && yarn dev'
$ nodemon src/index.js --exec babel-node
$ react-scripts start
[1] [nodemon] 1.19.0
[1] [nodemon] to restart at any time, enter `rs`
[1] [nodemon] watching: *.*
[1] [nodemon] starting `babel-node src/index.js`
[1] Browserslist: caniuse-lite is outdated. Please run next command `yarn upgrade`
[1] Checking for inactive rooms...
[1] Darkwire is online at port 3001
[1] events.js:183
[1] throw er; // Unhandled 'error' event
[1] ^
[1]
[1] Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED 127.0.0.1:6379
[1] at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1191:14)
[1] [nodemon] app crashed - waiting for file changes before starting...
[0] Starting the development server...
[0]
[0] Browserslist: caniuse-lite is outdated. Please run next command `yarn upgrade`
[0] Compiled successfully!
[0]
[0] You can now view darkwire-client in the browser.
[0]
[0] Local: http://localhost:3000/
[0] On Your Network: http://175.124.13.111:3000/
[0]
[0] Note that the development build is not optimized.
[0] To create a production build, use yarn build.
[0]
```
screenshot
I think maybe I have the wrong version Node.js and try install 9.x version, download again project and try again, it not help, try change port from 3001 to 3000, not help.
From their README.md
Darkwire Server
Darkwire server is a Node.js application that requires redis.
So please install a compatible redis server. Redis tutorial

webpack --progress Error: write EINVAL

I'm on Windows 10 recently upgraded my node.js to version 7.1.0. I started to get the following error every time I ran the webpack command with --progress flag.
$ webpack --progress
Node Environment: development events.js:160
throw er; // Unhandled 'error' event
^
Error: write EINVAL
at exports._errnoException (util.js:1022:11)
at WriteStream.Socket._writeGeneric (net.js:715:26)
at WriteStream.Socket._write (net.js:734:8)
at doWrite (_stream_writable.js:334:12)
at writeOrBuffer (_stream_writable.js:320:5)
at WriteStream.Writable.write (_stream_writable.js:247:11)
at WriteStream.Socket.write (net.js:661:40)
at E:\Projects\wad\node_modules\webpack\bin\convert-argv.js:421:20
at Compiler.<anonymous> (E:\Projects\wad\node_modules\webpack\lib\ProgressPlugin.js:77:4)
at Compiler.applyPlugins (E:\Projects\wad\node_modules\tapable\lib\Tapable.js:26:37)
at Compiler.<anonymous> (E:\Projects\wad\node_modules\webpack\lib\Compiler.js:193:12)
at Compiler.emitRecords (E:\Projects\wad\node_modules\webpack\lib\Compiler.js:282:37)
at Compiler.<anonymous> (E:\Projects\wad\node_modules\webpack\lib\Compiler.js:187:11)
at E:\Projects\wad\node_modules\webpack\lib\Compiler.js:275:11
at Compiler.applyPluginsAsync (E:\Projects\wad\node_modules\tapable\lib\Tapable.js:60:69)
at Compiler.afterEmit (E:\Projects\wad\node_modules\webpack\lib\Compiler.js:272:8)
at Compiler.<anonymous> (E:\Projects\wad\node_modules\webpack\lib\Compiler.js:267:14)
at E:\Projects\wad\node_modules\async\lib\async.js:52:16
at done (E:\Projects\wad\node_modules\async\lib\async.js:246:17)
at E:\Projects\wad\node_modules\async\lib\async.js:44:16
at E:\Projects\wad\node_modules\graceful-fs\graceful-fs.js:43:10
at FSReqWrap.oncomplete (fs.js:111:15)
It works fine without the --progress flag and webpack --progress was working fine on node.js v6.x.x. Using webpack --progress with node v.7.1.0 on the same project but another windows 10 machine also works fine.
What does this error mean?
This is a problem of the version node, use the version 6.9 and success
I had the same problem, and i uninstall node7.1, reboot and install node6.9 and all ok
It seems there a bug at node js v7.1.0 nodejs/node#9542. Update to the latest version v7.3.0 and everything will be ok.

Resources