1

I have just joined the angular community, and currently am working on a certain project, which has been going smoothly until I ran into a problems running jQuery, and after some research, some people suggested that I import jQuery into polyfills.ts as:

import * as jQuery from 'jquery';

window['$'] = jQuery

As a result, this showed some error suggesting I install @types/jquery. And after running:

C:\Users\Me\Apps\myProject> npm install --save-dev @types/jquery

The error/squiggly lines seem to have vanished but then it showed atleast 52 vulnerabilities. After running:

npm audit fix --force

Here seems like I have crashed everything, and every build returns a furious error as:

An unhandled exception occurred: require() of ES Module C:\Users\Me\Apps\myProject\node_modules\@angular\compiler-cli\bundles\index.js from 
C:\Users\Me\Apps\myProject\node_modules\@angular-devkit\build-angular\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js not supported.
Instead change the require of index.js in C:\Users\Me\Apps\myProject\node_modules\@angular-devkit\build-angular\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js to a dynamic import() which is available in all CommonJS modules.
See "C:\Users\Me\AppData\Local\Temp\ng-pYwjGj\angular-errors.log" for further details.

I have been, since then, scurrying the web just like a spider, but I don't seem to get anything to soothe it. Any help will be handsomely acknowledged.

N.B: I am using angular CLI ~13.1.2

Regards.

Amin Matola
  • 137
  • 2
  • 7
  • See if this helps - https://stackoverflow.com/q/30623825/3411606 – Aakash Goplani Jan 12 '22 at 19:38
  • I think the biggest issue for now is to solve the exception first. – Amin Matola Jan 12 '22 at 20:06
  • The reason I posted article link was for you to explore other (simple) ways to add jQuery to your project. If the way in which you have implemented is giving you problem, try for other approach mentioned in article wherein you just need to add reference to angular.json file which I believe is much simpler then messing with polyfill files! – Aakash Goplani Jan 12 '22 at 20:09
  • 1
    I just figured it out, it was version problems... I did npm audit fix --force again, and it upgraded, "Will install @angular-devkit/build-angular@13.1.2, which is a breaking change" – Amin Matola Jan 12 '22 at 20:32

1 Answers1

0

Delete the node_modules folder. That will uninstall all installed packages. To reinstall them run the following command:

npm install

There is no 100% gurantee, that it will fix your problem, but it could help you by solving some of your vulnerabilities.

SwissCodeMen
  • 4,222
  • 8
  • 24
  • 34
Tim
  • 11
  • 2