Running npm run start with Node.js 22 gives following error in the browser when http://localhost:3010 is loaded:
Compiled with problems:
×
WARNING in ./node_modules/.pnpm/asn1.js@4.10.1/node_modules/asn1.js/lib/asn1/api.js 21:12-42
Module not found: Error: Can't resolve 'vm' in 'R:\yscope-log-viewer\node_modules\.pnpm\asn1.js@4.10.1\node_modules\asn1.js\lib\asn1'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
add a fallback 'resolve.fallback: { "vm": require.resolve("vm-browserify") }'
install 'vm-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "vm": false }
2. Previously the issue was only observed in newly cloned repos because the package-lock.json was not committed to the git repo and only newer `npm` versions decide to install a version of `asn1.js` that references "vm". To ensure reproducibility of dev environments, we should add `package-lock.json` to the VCS.
Description
Update webpack settings to exclude 'vm' polyfill to avoid the warning from showing up.
Add package-lock.json to VCS.
Validation performed
Ran npm run start again and observed no such warning as described in the above "Reference" section.
References
npm run start
with Node.js 22 gives following error in the browser when http://localhost:3010 is loaded:BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default. This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
Description
package-lock.json
to VCS.Validation performed
npm run start
again and observed no such warning as described in the above "Reference" section.