NPM was working fine until today and suddenly I am getting this error for any NPM command.
Even : npm -v
Produces the error : npm ERR! Workspaces not supported for global packages
It's always just worked for me in the past so I really don't know much about how it works so struggling to fix this.
As far as I know, I updated nothing so not sure why it would suddenly stop working.
Driving me mad as I cannot work on my projects using SASS
I tried uninstalling NODE.JS and reinstalling but no luck.
VERSION INFO
NODE v18.16.0
NPM v9.5.1
Solution:
Reinstall npm: Uninstall the current npm and download and install the latest version of npm.
Check environment variables: Make sure there are no abnormal paths related to npm set in the system's environment variables.
Delete residual folders: Manually delete the following folders (if they exist) to ensure complete removal:
C:\Users**\AppData\Roaming\npm
OR %AppData%/npm
C:\Users**\AppData\Roaming\npm-cache
OR %AppData%/npm-cache
C:\Users**.npmrc
(this file is likely the main issue)C:\Program Files\nodejs
(default installation path for Node.js)
** Replace ** with your computer username.Reinstall Node.js: Download the latest version of the Node.js installer and install it using the default settings.
This should resolve the issue.