Currently, I am addressing some vulnerability concerns within my Angular development environment. These vulnerabilities are found within internal dependencies, so I have included resolutions in the package.json file. However, when I attempt to run 'ng serve', I encounter the following error:
An unhandled exception occurred: Must use import to load ES Module:
C:\..\..\node_modules\strip-ansi\node_modules\ansi-regex\index.js
require() of ES modules is not supported.
require() of C:\kowshik\orch-ui\node_modules\strip-ansi\node_modules\ansi- regex\index.js from C:\..\..\node_modules\strip-ansi\index.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename C:\..\..\node_modules\strip-ansi\node_modules\ansi-regex\index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from C:\..\..\node_modules\strip-ansi\node_modules\ansi- regex\package.json.
The steps I have taken are as follows:
I have updated the resolutions in my package.json file.
"resolutions": { "ansi-regex": "6.0.1", "glob-parent": "6.0.2", "set-value": "4.1.0", "url-parse": "1.5.8", "minimist": "1.2.6", "querystring ": "6.10.3", "node-forge": "1.3.0" },
Removed the node_modules directory.
Executed 'npm cache clean' command.
Used 'npx npm-force-resolutions'.
Ran 'npm i' to install dependencies.
If anyone can offer assistance in resolving this issue, it would be greatly appreciated.