npm ERR! Cannot read properties of undefined (reading ‘stdin’)

Photo by burak kostak from Pexels


Just sharing a possible solution for this error. I received this after installing a new version of Node.js and spent hours trying to figure how to run my React and Angular projects. The solution below may not be ideal, but it will get you your applications to run until you figure out the most current version of NPM to install.

Snapshot of the error

C:\Projects\react-demo-app>npm start

> react-demo-app@0.1.0 start
> react-scripts start

npm ERR! Cannot read properties of undefined (reading 'stdin')

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Username\AppData\Local\npm-cache\_logs\2022-02-194T16_18_33_034Z-debug-0.log

If you already tried the following:

npm cache clear --force

And deleted the node_modules folder and package.lock.json and ran the following:

npm install

And it still doesn’t work, consider the solution below.


Reinstall Node.js

First uninstall node.js and restart the machine. Then install an older version like 14.7.3. Direct link here for Window 10

Downgrade NPM

Another option is to downgrade NPM to the last known working version used to build your applications.

Example to downgrade from 8.3.1 to 6.14.6.

npm install -g npm@6.14.6

If you get the following error:

Delete the npm folder/files from “C:\Users\YOURUSERNAME\AppData\Roaming\npm”
Then try to install npm@version again.

If you still get an error when trying to install a new library, then remove the package-lock.json file and try again.

Check the version

npm -v

You should see 6.14.6 or the version you chose to downgrade to.

Hope this helps 🙂

Photo by Lynnelle Richardson from Pexels