'npm run build fails after updating npm (EACCES: permission denied)

I have a CRA (create-react-app) and I updated npm. Following, npm run build started to fail with error:

EACCES: permission denied, rmdir 'PATH/build/static/css'

My npm version is, npm -v:

7.22.0

And my scripts in package.json is:

  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
  },

Running the command with sudo didn't help, before updating to npm (from version 6.X) this problem wasn't occuring.



Solution 1:[1]

as @apokryfos suggested, removing build/static/css manually and running build solves the issue.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sinan Yaman