I have installed compression-webpack-plugin using this link and added Compression plugin in plugin section of webpack.config.js file as suggested here
When I run npm run build I am getting an error
Algorithm "brotliCompress" is not found in "zlib"
I am using node v8.11.3.
Here is the full error
C:\Projects\ProjName\FrontEnd\node_modules\webpack-cli\bin\cli.js:93
throw err;
^
Error: Algorithm "brotliCompress" is not found in "zlib"
at new CompressionPlugin (C:\Projects\ProjName\FrontEnd\node_modules\compression-webpack-plugin\dist\index.js:171:15)
at Object. (C:\Projects\ProjName\FrontEnd\webpack\webpack.config.prod.js:67:5)
at Module._compile (C:\Projects\ProjName\FrontEnd\node_modules\v8-compile-cache\v8-compile-cache.js:192:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (C:\Projects\ProjName\FrontEnd\node_modules\v8-compile-cache\v8-compile-cache.js:159:20)
at WEBPACK_OPTIONS (C:\Projects\ProjName\FrontEnd\node_modules\webpack-cli\bin\utils\convert-argv.js:114:13)
at requireConfig (C:\Projects\ProjName\FrontEnd\node_modules\webpack-cli\bin\utils\convert-argv.js:116:6)
at C:\Projects\ProjName\FrontEnd\node_modules\webpack-cli\bin\utils\convert-argv.js:123:17
at Array.forEach ()
at module.exports (C:\Projects\ProjName\FrontEnd\node_modules\webpack-cli\bin\utils\convert-argv.js:121:15)
at yargs.parse (C:\Projects\ProjName\FrontEnd\node_modules\webpack-cli\bin\cli.js:71:45)
at Object.parse (C:\Projects\ProjName\FrontEnd\node_modules\webpack-cli\node_modules\yargs\yargs.js:576:18)
at C:\Projects\ProjName\FrontEnd\node_modules\webpack-cli\bin\cli.js:49:8
at Object. (C:\Projects\ProjName\FrontEnd\node_modules\webpack-cli\bin\cli.js:366:3)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object. (C:\Projects\ProjName\FrontEnd\node_modules\webpack\bin\webpack.js:156:2)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Function.Module.runMain (module.js:693:10)
at startup (bootstrap_node.js:191:16)
at bootstrap_node.js:612:3 npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! ProjName#1.0.0 build: npm run buildsprite && webpack --config ./webpack/webpack.config.prod.js --colors npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the ProjName#1.0.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!
C:\Users\2048537\AppData\Roaming\npm-cache_logs\2021-12-29T09_59_46_237Z-debug.log
This is how I injected the plugin
new CompressionPlugin({
filename: "[path][base].br",
algorithm: "brotliCompress",
test: /\.(js|css|html|svg)$/,
compressionOptions: {
params: {
[zlib.constants.BROTLI_PARAM_QUALITY]: 11,
},
},
threshold: 10240,
minRatio: 0.8,
deleteOriginalAssets: false,
}),
Looks like webpack team needs to update https://webpack.js.org/plugins/compression-webpack-plugin/#using-brotli link.
I replace plugin code as below as below
new BrotliGzip({
asset: '[file].br[query]',
algorithm: "brotli",
test: /\.(js|css|html|svg)$/,
threshold: 10240,
minRatio: 0.8,
quality: 11
}),
where BrotliGzip is defined as
const BrotliGzip = require("brotli-gzip-webpack-plugin");
then it worked.
Related
I follow the instructions in https://github.com/iden3/rapidsnark to complile the code.
When I try to run "npx task createFieldSources" in my ubuntu in wsl, I get the following errors:
superduper#DESKTOP-PC181T0:/mnt/d/github/4.prove_verify/circuits$ npm install
added 1 package, and audited 2 packages in 3s
found 0 vulnerabilities
superduper#DESKTOP-PC181T0:/mnt/d/github/4.prove_verify/circuits$ git submodule init
superduper#DESKTOP-PC181T0:/mnt/d/github/4.prove_verify/circuits$ git submodule update
superduper#DESKTOP-PC181T0:/mnt/d/github/4.prove_verify/circuits$ npx task createFieldSources
Error: Cannot find module './uws_linux_108'
Require stack:
- /home/superduper/.npm/_npx/366785b987801bcc/node_modules/hub.js/dist/index.js
- /home/superduper/.npm/_npx/366785b987801bcc/node_modules/task/src/index.js
- /home/superduper/.npm/_npx/366785b987801bcc/node_modules/task/bin/cmd.js
at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
at Module._load (node:internal/modules/cjs/loader:841:27)
at Module.require (node:internal/modules/cjs/loader:1061:19)
at require (node:internal/modules/cjs/helpers:103:18)
at /home/superduper/.npm/_npx/366785b987801bcc/node_modules/hub.js/dist/index.js:239:14
at Object.<anonymous> (/home/superduper/.npm/_npx/366785b987801bcc/node_modules/hub.js/dist/index.js:244:3)
at Module._compile (node:internal/modules/cjs/loader:1159:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
at Module.load (node:internal/modules/cjs/loader:1037:32)
at Module._load (node:internal/modules/cjs/loader:878:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/home/superduper/.npm/_npx/366785b987801bcc/node_modules/hub.js/dist/index.js',
'/home/superduper/.npm/_npx/366785b987801bcc/node_modules/task/src/index.js',
'/home/superduper/.npm/_npx/366785b987801bcc/node_modules/task/bin/cmd.js'
]
}
/home/superduper/.npm/_npx/366785b987801bcc/node_modules/hub.js/dist/index.js:246
$197449592_native.setNoop($197449592_noop)
^
TypeError: Cannot read properties of undefined (reading 'setNoop')
at Object.<anonymous> (/home/superduper/.npm/_npx/366785b987801bcc/node_modules/hub.js/dist/index.js:246:19)
at Module._compile (node:internal/modules/cjs/loader:1159:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
at Module.load (node:internal/modules/cjs/loader:1037:32)
at Module._load (node:internal/modules/cjs/loader:878:12)
at Module.require (node:internal/modules/cjs/loader:1061:19)
at require (node:internal/modules/cjs/helpers:103:18)
at Object.<anonymous> (/home/superduper/.npm/_npx/366785b987801bcc/node_modules/task/src/index.js:1:11)
at Module._compile (node:internal/modules/cjs/loader:1159:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
Node.js v18.12.1
How could I fix them?
Error: Cannot find module 'react-dev-utils/WatchMissingNodeModulesPlugin'
Require stack:
- C:\Users\stromboli\IdeaProjects\projects-ui\config\webpack.config.js
- C:\Users\stromboli\IdeaProjects\projects-ui\scripts\start.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1014:15)
at Function.Module._load (internal/modules/cjs/loader.js:884:27)
at Module.require (internal/modules/cjs/loader.js:1074:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (C:\Users\stromboli\IdeaProjects\projects-ui\config\webpack.config.js:18:39)
at Module._compile (internal/modules/cjs/loader.js:1185:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1205:10)
at Module.load (internal/modules/cjs/loader.js:1034:32)
at Function.Module._load (internal/modules/cjs/loader.js:923:14)
at Module.require (internal/modules/cjs/loader.js:1074:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (C:\Users\stromboli\IdeaProjects\projects-ui\scripts\start.js:32:23)
at Module._compile (internal/modules/cjs/loader.js:1185:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1205:10)
at Module.load (internal/modules/cjs/loader.js:1034:32)
at Function.Module._load (internal/modules/cjs/loader.js:923:14) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\stromboli\\IdeaProjects\\projects-ui\\config\\webpack.config.js',
'C:\\Users\\stromboli\\IdeaProjects\\projects-ui\\scripts\\start.js'
]
}
No matter what I do localhost won't open and I get this error. The github solutions shown didn't work either, how can I fix it I'm about to go crazy.
npm ls react-dev-utils
`-- react-dev-utils#12.0.1
In your config find webpack.config.dev.js and remove the following:
const WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin');
module.exports = {
// ...
plugins: [
// If you require a missing module and then `npm install` it, you still have
// to restart the development server for Webpack to discover it. This plugin
// makes the discovery automatic so you don't have to restart.
// See https://github.com/facebook/create-react-app/issues/186
new WatchMissingNodeModulesPlugin(paths.appNodeModules),
]
}
node:fs:723
handleErrorFromBinding(ctx);
^
Error: EIO: i/o error, read
at Object.readSync (node:fs:723:3)
at tryReadSync (node:fs:433:20)
at Object.readFileSync (node:fs:471:19)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1120:18)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object. (C:\Program Files\nodejs\node_modules\npm\lib\utils\exit-handler.js:4:22)
at Module._compile (node:internal/modules/cjs/loader:1103:14) {
errno: -4070,
syscall: 'read',
code: 'EIO'
}
$ npx create-react-app counter
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module 'block-stream'
Require stack:
C:\Users\theop\AppData\Local\npm-cache_npx\c67e74de0542c87c\node_modules\tar\lib\entry-writer.js
C:\Users\theop\AppData\Local\npm-cache_npx\c67e74de0542c87c\node_modules\tar\lib\pack.js
C:\Users\theop\AppData\Local\npm-cache_npx\c67e74de0542c87c\node_modules\tar\tar.js
C:\Users\theop\AppData\Local\npm-cache_npx\c67e74de0542c87c\node_modules\create-react-app\node_modules\tar-pack\index.js
C:\Users\theop\AppData\Local\npm-cache_npx\c67e74de0542c87c\node_modules\create-react-app\createReactApp.js
C:\Users\theop\AppData\Local\npm-cache_npx\c67e74de0542c87c\node_modules\create-react-app\index.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object. (C:\Users\theop\AppData\Local\npm-cache_npx\c67e74de0542c87c\node_modules\tar\lib\entry-writer.js:7:19)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\Users\theop\AppData\Local\npm-cache\_npx\c67e74de0542c87c\node_modules\tar\lib\entry-writer.js',
'C:\Users\theop\AppData\Local\npm-cache\_npx\c67e74de0542c87c\node_modules\tar\lib\pack.js',
'C:\Users\theop\AppData\Local\npm-cache\_npx\c67e74de0542c87c\node_modules\tar\tar.js',
'C:\Users\theop\AppData\Local\npm-cache\_npx\c67e74de0542c87c\node_modules\create-react-app\node_modules\tar-pack\index.js',
'C:\Users\theop\AppData\Local\npm-cache\_npx\c67e74de0542c87c\node_modules\create-react-app\createReactApp.js',
'C:\Users\theop\AppData\Local\npm-cache\_npx\c67e74de0542c87c\node_modules\create-react-app\index.js'
]
}
I thought you installed block-stream first
npm init && npm i block-stream && npx create-react-app counter
or using vite
npm create vite#latest my-vue-app -- --template react
I am getting below error while trying to execute below command
npm-check-updates
internal/modules/cjs/loader.js:905
throw err;
^
Error: Cannot find module '../../package.json'
Require stack:
C:\Users\hbarsainya\AppData\Roaming\npm\node_modules\npm-check-updates\build\src\bin\cli.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
at Function.Module._load (internal/modules/cjs/loader.js:746:27)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:92:18)
at Object. (C:\Users\hbarsainya\AppData\Roaming\npm\node_modules\npm-check-updates\build\src\bin\cli.js:11:40)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\Users\hbarsainya\AppData\Roaming\npm\node_modules\npm-check-updates\build\src\bin\cli.js'
]
}
I see the location C:\Users\hbarsainya\AppData\Roaming\npm\node_modules\npm-check-updates\build\src\bin\cli.js exist. Can you help me solving this error?
I found the workaround in location https://github.com/raineorshine/npm-check-updates/issues/990
I changed "../../package.json" to "../../../package.json" in /home/ledsun/.local/share/nvm/v17.0.1/lib/node_modules/npm-check-updates/build/src/bin/cli.js:11, then the ncu runs expected.