admin管理员组

文章数量:1419194

I tried ES imports statements and normal script tag to import the required JS file and CSS file for bootstrap in astro js project

I am getting this Issue.

Error: The following dependencies are imported but could not be resolved:

js/jquery-3.4.1.min.js (imported by /media/****li/hdd/***ed-astro/src/layouts/main.astro) js/bootstrap.js (imported by /media/****li/hdd/***ed-astro/src/layouts/main.astro) js/custom.js (imported by /media/****li/hdd/***ed-astro/src/layouts/main.astro)

Are they installed?

I tried ES imports statements and normal script tag to import the required JS file and CSS file for bootstrap in astro js project

I am getting this Issue.

Error: The following dependencies are imported but could not be resolved:

js/jquery-3.4.1.min.js (imported by /media/****li/hdd/***ed-astro/src/layouts/main.astro) js/bootstrap.js (imported by /media/****li/hdd/***ed-astro/src/layouts/main.astro) js/custom.js (imported by /media/****li/hdd/***ed-astro/src/layouts/main.astro)

Are they installed?

Share Improve this question edited May 12, 2022 at 6:04 Abdeali Chandanwala asked Jan 23, 2022 at 17:44 Abdeali ChandanwalaAbdeali Chandanwala 8,8486 gold badges33 silver badges49 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 2

Got it, in the main layout file - I had to rectify the file path

From

<script src="js/custom.js"></script>

TO

<script src="assets/js/custom.js"></script>

same for all CSS file ..

all these assets were places in the public folder.

For me, I had to set type="text/javascript" It wasn't working till I added that.

Use craigmichaelmartin's solution from https://stackoverflow./a/51271892/1510777.

Short version: Add a jQuery loader module using the code below, and import that instead of 'jquery'.

import {$,jQuery} from 'jquery';
window.$ = $;
window.jQuery = jQuery;
export default $;
export { jQuery };

本文标签: javascriptI want to import bootstrap js and jquery js file in astro jsStack Overflow