📅  最后修改于: 2022-03-11 15:04:02.386000             🧑  作者: Mango
First, you will have to remove the npm cache and upgrade to the latest version of the node and npm will resolve the issue.
sudo npm cache clean -f
sudo npm install -g n install n
sudo n stable
The first command will force clean the npm package manager's cache, After the second and third commands, a stable version of the node and npm will be installed. then you can execute **npm i** and **npm run build** for creating an optimized production build.
This solution worked for the same error on the **npm run build** command in nextjs.