Jquery not working in angular 6 Error: ENOENT: no such file or directory, open '…\node_modules\jquery\dist\jquery.min.js'

前端 未结 11 1797
离开以前
离开以前 2021-02-01 02:02

I am in process migrating Angular 5 project to Angular 6.

While starting application by

npm start

getting the below error



        
11条回答
  •  轮回少年
    2021-02-01 02:30

    I had a similar issue...

    The Jquery plugin didn't have an npm package ready : (
    So I decided to put it inside the assets folder...
    Evidently that didn't work.
    so I did some testing...

    Here's what worked for me:

    • Navigate to node_modules/jquery/dist/

    • — and simply insert the plugin file there.

    • Once this is done change your angular.json file
      from:

      "scripts": [ "node_modules/jquery/dist/jquery.min.js", "../assets/libraries/okshadow.min.js" ]

    To:

    "scripts": [
          "node_modules/jquery/dist/jquery.min.js",
          "node_modules/jquery/dist/okshadow.min.js"
    ]
    

    And your all set!

    P.S. This is on Angular 7.0 rather than Angular 6

提交回复
热议问题