npm ERR! Unexpected token ! in JSON at position 0 while parsing near ‘!function(){var a=”/…’

I’m facing an issue when I try to install the npm on my node project. I tried to clean the npm cache and downgraded the node also but error is not fixed.

node - v14.17.6
npm - 6.14.8
npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN deprecated circular-json@0.3.3: CircularJSON is in maintenance only, flatted is its successor.
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm ERR! Unexpected token ! in JSON at position 0 while parsing near '!function(){var a="/...'

npm ERR! A complete log of this run can be found in:

Answer

I solved the problem by running this command:

npm config set registry https://registry.npmjs.org/