React Netlify Error Wants Me To Install Nonexistent Vm-Browserify Package?

I have a react app that I recently scaffolded with create-react-app.

When I run npm run build locally on node v20.18.0 it works fine with no erros.

When I connect my repo to netlify and let it build set to node v20 I see this error in the build logs:

12:02:30 AM: 
12:02:30 AM: Treating warnings as errors because process.env.CI = true.
12:02:30 AM: Most CI servers set it automatically.
12:02:30 AM: 
12:02:30 AM: Failed to compile.
12:02:30 AM: 
12:02:30 AM: Module not found: Error: Can't resolve 'vm' in '/opt/build/repo/my-app/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.
12:02:30 AM: This is no longer the case. Verify if you need this module and configure a polyfill for it.
12:02:30 AM: If you want to include a polyfill, you need to:
12:02:30 AM: 	- add a fallback 'resolve.fallback: { "vm": require.resolve("vm-browserify") }'
12:02:30 AM: 	- install 'vm-browserify'
12:02:30 AM: If you don't want to include a polyfill, you can use an empty module like this:
	resolve.fallback: { "vm": false }
12:02:30 AM: [eslint]
12:02:30 AM: src/App.tsx

Strange that I’m only seeing it on Netlify and not locally, but ok fine- I’ll try to install “vm-browserify” as it recommends.

When I try though to run npm i vm-browserify I just get an error that it can’t be found:

npm error Cannot read properties of null (reading ‘matches’)

Huh? What’s going on here? How can I build my React app on Netlify?

Thanks!

Hi, @Jimb0. It looks like you resolved the issue on your own. Please feel free to share your solution here as this would like help others in a similar situation.

However, if I am mistaken and the issue persists, please do let us know here.

Thanks @luke

The problem turned out to be that my app was meant to be installed with “pnpm” and not “npm”.

For some reason I had run npm install locally which created a package-lock.json file, and I guess netlify assumed that because of that I wanted it to run npm install.

After I deleted the package-lock.json and pushed it started correctly running pnpm i.

Just an idea, it might be nice to have an input field to allow users to enter their own install command the way you allow the build command. Run now the process for customizing this install command is not very straightforward imo…