Error encountered while building with Vite: Parsing issue when importing PNG images in a Vue.js project

While working on my app, I encountered a problem. In my code, I have the following line:

<img
            class="h-full w-full object-cover"
            src="../assets/img/loginSignUpForms/Login.PNG"
            alt=""
          />

However, I received a strange error message:

1: PNG
2: →
IHDR♥▬♥♠1Z☺sRGB∟♦gAMA♂a♣        pHYs♫♫☺odIDATx^mQs⌂5M#}E▲ew☻K ...
                                                                                                            ^
4: A:`♫?sc}♣oXҍF|- W▲:‼_ϗp<⌂gܦ~♂x↨<☺d‼d>:qyd♥.→Y9l+ ?҅?...
23~_⌂[... ∟↔▲0♂ׄhMX♂dh$iaXp▬E♥§DҺL_{oqU♦G}▬C%7u⌂rm<ՃQ|>
error during build:
Error: Parse error @:3:106
    at parse$e (file:///C:/Users/user/Desktop/JSQuizz/client/node_modules/vite/dist/node/chunks/dep-52909643.js:16497:355)
    at Object.transform (file:///C:/Users/gofrf/Desktop/JSQuizz/client/node_modules/vite/dist/node/chunks/dep-52909643.js:46653:27)

After researching, I learned that I should move the image to the public directory in my project. So, the corrected image code looks like:

 <div name="left" class="w-[100%] lg:w-[50%]">
          <img class="h-full w-full object-cover" src="/Login.PNG" alt="" />
        </div>

However, now I am facing a different error:

[vite]: Rollup failed to resolve import "/Login.PNG" from "C:/Users/user/Desktop/JSQuizz/client/src/views/LoginAndSignIn.vue".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
`build.rollupOptions.external`
error during build:
Error: [vite]: Rollup failed to resolve import "/Login.PNG" from "C:/Users/gofrf/Desktop/JSQuizz/client/src/views/LoginAndSignIn.vue".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to

Answer №1

Encountering a similar issue, I received the following error message:

Error: Parse error @:3:726 at parse$e (file:///C:/Users/SuperJo/Desktop/building%20website/node_modules/vitepress/node_modules/vite/dist/node/chunks/dep-64acfab2.js:16378:355)
at Object.transform (file:///C:/Users/SuperJo/Desktop/building%20website/node_modules/vitepress/node_modules/vite/dist/node/chunks/dep-64acfab2.js:46247:27)

After converting the PNG to a jpg image format, the issue was resolved successfully.

For reasons unknown to me, the conversion resolved the problem.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Why does the outcome of running this code vary each time?

I've been working on a code project to create 10 bouncing balls of different colors, but I'm encountering an issue where only one or two balls appear with different colors or the animation works perfectly only 1 out of 10 times. Any thoughts on w ...

What is the optimal method for organizing MongoClient and express: Should the Client be within the routes or should the routes be within the client?

Which is the optimal way to utilize MongoClient in Express: placing the client inside routes or embedding routes within the client? There are tutorials showcasing both methods, leaving me uncertain about which one to adopt. app.get('/',(req,res) ...

Finding and comparing a specific portion of a text in JavaScript: A guide

Can you help me with a JavaScript algorithm that can find a substring within a string? subStringFinder('abbcdabbbbbck', 'ab') This should return index 0. Similarly, subStringFinder('abbcdabbbbbck', 'bck') should ...

``What is the best way to include a JavaScript jQuery variable value within a PHP array

Let's consider the following scenario: var folderName = jQuery.trim($('#dirname').val()); var parentFolder = jQuery.trim($('#parent').val()); var dynamicUrl = '<?=$this->url(array('controller'=>'index ...

TS2307 Error: The specified module (external, private module) could not be located

I have come across similar queries, such as tsc throws `TS2307: Cannot find module` for a local file . In my case, I am dealing with a private external module hosted on a local git server and successfully including it in my application. PhpStorm is able ...

What methods does Angular use to display custom HTML tags in IE9/10 without causing any issues for the browser?

Exploring web components and utilizing customElements.define tends to cause issues in IE9/10. I've noticed that Angular is compatible with IE9/10, and upon inspecting the DOM tree, it seems like Angular successfully displays the custom element tags. ...

The result of JWT.decode may be null

I am facing an issue with decoding a JSON web token as it is returning null. I have even tried setting complete set to true, but unfortunately it still fails. The function used for generating the token is: import jwt from 'jsonwebtoken'; jwt.s ...

Function is not triggered in React component

When the LoginPage calls AuthForm, the structure is as follows: function mapDispatchToProps(dispatch: Redux.Dispatch<any>) { return { signUpWithEmail: function(email: string, password: string) { // bla bla }, }; } handleForm ...

I encountered an issue with route handlers in Next.js version 13.2. Sadly, they are not

I am trying to implement an API on my website with the endpoint /api/popular-movie. Here is an overview of my file structure: https://i.stack.imgur.com/e8Pf8.png Additionally, this is my route.ts code: import { NextResponse } from "next/server"; ...

Tips for modifying animations based on screen width thresholds

Currently, I've implemented the data-aos attribute to add a "fade-up-right" animation to an element on my website, as shown below: <div className="des__Container" data-aos="fade-up-right"> However, I now want to modify this ...

Retrieve information from an external JSON API using jQuery

I need help with reading JSON data using jQuery. I have tried the code below but it doesn't seem to be working. This is the link to my JSON file: and here is my code snippet: $.getJSON("http://goo.gl/PCy2th", function(data){ $.each(data.PlayList ...

In TypeScript, how are angle brackets like methodName<string>() utilized?

Could someone please assist me in understanding why we use angular brackets <> in typescript? For example, I have provided some code below and would appreciate an explanation. export class HomePage { constructor(public navCtrl: NavController) ...

Express.js encountering an `ERR_HTTP_HEADERS_SENT` issue with a fresh Mongoose Schema

My Objective Is If data is found using the findOne() function, update the current endpoint with new content. If no data is found, create a new element with the Schema. Issue If there is no data in the database, then the first if statement throws an ERR_H ...

Utilizing Vuetify's V-File-input component along with an append-outer-icon functionality

Looking to customize the v-file-input icon and its placement? I tried using the "append-outer-icon" attribute to achieve this, but unfortunately clicking on the icon doesn't trigger any action. Ideally, I would like to click on the "append-outer-icon" ...

Ways to retrieve the text of the <Label> element without relying on the "id" attribute

I have a challenge in extracting text enclosed within the `Label` tag. My knowledge of Javascript and JQuery is limited, so I require guidance on accomplishing this task. Currently, I am attempting to use code that I found on a stackoverflow post titled ge ...

Issue with Angular ui-select causing repeated $http requests in ui-select-choices

I'm currently working on integrating ui-select into my project, and this time I need to pass a controller function as options to ui-select-choices. Here's how it's set up: HTML: <ui-select ng-model="selectedItem" theme="selectize" ng-di ...

JavaScript encountering errors while parsing JSON data

I'm struggling to filter some JSON information and display it in HTML classes. Despite my efforts, I can't seem to make it work. I feel like I'm not getting it. Can someone please assist me with this? $.ajax({ // Agenda type: ' ...

Alter the data displayed by the Radio button using Angular when the Submit button is clicked

I've encountered an issue where I need to alter a div based on the selection of a radio button. Currently, it changes instantly upon button click, rather than waiting for submission. My desired outcome is for the value to be submitted when the button ...

Using an external variable within an internal function in TypeScript

I am facing a situation where I have a variable outside of a function that needs to be updated, but I am unable to access it using "this" as it is not reachable at that point in the code. export class GamesDetailPage { details : any = {}; type : St ...

Retrieving Value from Dynamic Content Using jQuery `.keypress()` and `.delegate()`

I have encountered an issue with my code that is unable to retrieve the value of a specific ID on the .keypress function after using .delegate. The ID and other contents are generated dynamically through an AJAX call. $(document).delegate('.edit_ ...