Solution:
Delete your package-lock.json
file and node_modules
folder. Later perform npm cache clean
npm cache clean --force
exercise npm install
again and run
Lastly, I figure out a solution to this issue without reinstalling npm and I'm posting it since in future it will help someone, Most of the time this error happens javascript heap went out of the memory. As the error tells itself this is not a problem with npm. Just we have to do is
instead of,
npm run build -prod
Enhance the javascript memory by following,
node --max_old_space_size=4096 node_modules/@angular/cli/bin/ng build --prod
Inside that directory, you can run various commands:
npm start
Starts the development server.
npm run build
Bundles the app into static files for production.
npm test
Starts the test runner.
npm run eject
Removes this tool and copies build dependencies, configuration files
and scripts into the app directory. If you do this, you can’t go back!
We suggest that you begin by typing:
cd myapp
npm start