You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Angular项目安装Bootstrap报错求助:找不到jQuery文件

Fixing the "jQuery File Not Found" Error in Angular Bootstrap Setup

Hey there, let's sort out this missing jQuery file issue quickly. Here's what's going wrong and how to fix it step by step:

1. Confirm jQuery is Properly Installed in Your Project

First, let's make sure jQuery actually exists in your Demo project's local node_modules folder. Navigate to your project root (D:\Angular\Demo) and check if there's a node_modules/jquery/dist folder containing jquery.min.js. If it's missing, re-run the install command in your project's terminal to ensure jQuery is installed locally:

npm install jquery --save

2. Correct the Paths in angular.json

The core problem here is the incorrect path syntax you used. Since angular.json lives directly in your project root, using ../node_modules tells the system to look for node_modules in the parent folder (D:\Angular) instead of your project's own local node_modules.

Update your styles and scripts sections in angular.json to use the correct relative paths:

"styles": [
  "src/styles.css",
  "node_modules/bootstrap/dist/css/bootstrap.css"
],
"scripts": [
  "node_modules/jquery/dist/jquery.min.js",
  "node_modules/bootstrap/dist/js/bootstrap.js"
]

(Note: I adjusted the styles.css path to Angular's default location src/styles.css—if your styles file is in a custom spot, keep that path accurate, but the Bootstrap/jQuery paths are the key fix here.)

3. Restart the Angular Development Server

Changes to angular.json don't take effect until you restart the dev server. Stop your current ng serve process (press Ctrl + C in the terminal), then re-run:

ng serve

Your server should now load jQuery and Bootstrap without the file-not-found error.


内容的提问来源于stack exchange,提问作者Lewis

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 07:04:44