Error encountered: JSON parsing failed due to an unexpected token 'm' at the beginning of the data while

I am brand new to coding and am currently trying to follow the lecturer's instructions on webpacks. However, every time I attempt to use the command "npx webpack", I encounter this error message: "/home/ubuntu/workspace/assignment1/hellowp/webpack.config.json: Unexpected token m in JSON at position 0"

Could someone please advise me on how to resolve this issue?

module.exports = {
    entry: './src/app.js',
        output: {
        filename: 'app.bundle.js',
    path: __dirname + '/dist'
    }
};

Here is my package.json file:

{
  "name": "hellowp",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "webpack": "^4.10.1",
    "webpack-cli": "^2.1.4"
  },
  "dependencies": {
    "jquery": "^3.3.1"
  }
}

Content of app.js file:

import $ from "jquery";

$(document).ready(function(){
    $('#intro').html("Hello Webpack");
})

  <div id='intro'></p>
  <script src='./dist/app.bundle.js'></script>
  
  // Content within my HTML file

Answer №1

Modify the filename to webpack.config.js instead of .json

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

Modifying dictionary post deserialization of JSON in C#

Hi there! I have a Json object that looks like this: { "login": { "login1": { "password": "Password123", "username": "admin1" }, "login2": { "password": "Password123", "username": "admin2" } } } I have created ...

The React.js navigation bar hamburger menu refuses to close when toggled

Currently, my team and I have developed a react.js application together. The Navbar feature is functioning correctly, except for a small issue. When the Navbar is toggled using the Hamburger menu on a smaller screen, it opens successfully, but the toggle a ...

Video with dynamic sizing doesn't adapt properly

I successfully achieved my main goal, which was to have a background video at the top of my page. However, I am facing an issue with making the video responsive. Currently, as I decrease the screen size, the video shrinks in both width and height rather th ...

Removing other objects with Mongoose after an update

I'm facing an issue with my update query in mongoose. I can't figure out why other objects are getting deleted when I only intend to update one specific object. The code is functioning correctly in terms of updating, but it's causing all the ...

Facing issue with local redis session not functioning as intended

I'm encountering an issue with my redis session not functioning properly when testing locally. EDIT: Additionally, I realized that it's failing to save a cookie when trying to set req.session[somekey] as undefined like so: req.session.user = u ...

Tips for generating a JSON-driven table in Angular 2

I'm attempting to build a dynamic datagrid in angular2 using a JSON object as the source. The challenge I face is not knowing the structure of the columns within the table, making it difficult to render the rows properly. My understanding is that I n ...

no data in next-redux-wrapper

I've been struggling to get my Next.js app working with getServerSideProps() for server-side rendering. I attempted to use next-redux-wrapper but the state is coming back empty. *Note: Redux was functioning properly while on the client side, but now ...

Sending DOM values to React components as properties

Forgive me if this question seems basic, as I am still learning ReactJs. I have a react component that displays the user's sign-in status: <AccountStatus iconsize="medium" activate={[true,false,true]}/> Image 1 //or using <AccountStatus i ...

Running a node.js project on the client side without using npm for deployment

Looking for a solution to efficiently deploy my nodejs project with frequent updates. The site does not have npm available, so I have to package the node_modules every time, which results in a large file size (80MB) that takes a long time to send via ftp t ...

Executing an Ajax request for multiple elements within a class using Jquery

My table contains 3 rows, each with 3 td elements. The first 2 td in each row have default values, while the last td in each row has an attribute called letter and a class called loader. Above the table is a button. I am trying to achieve the following: wh ...

unable to retrieve the data from the secondary dynamic cascading dropdown menu

Hopefully, my day's troubles will be resolved by now. I am facing an issue with two drop-down boxes. After submitting, only the value of the first dropdown box is available in the action page. The second dropdown box is dependent on the selection made ...

Adapting imports in Typescript for seamless npm distribution

Currently, I'm facing an issue with module resolution while compiling my NPM package written in Typescript for publishing. In my project, I've been using non-relative imports to avoid the hassle of excessive ../../../. However, according to TypeS ...

Issues with JSON.parse in node.js on Windows 8.1 system

I've encountered an issue with the JSON.parse function in node.js on Windows, resulting in this error message in my command line: SyntaxError: Unexpected token ´╗┐ at Object.parse <native> at R:\filelocation\server\server.js ...

Why is it that the function `val()` cannot be used with `$("#id")`?

jsp : <input id="companyName" class="cpn" type="text" value="" ></input> <input id="phoneNumber" class="number" type="text" value=""></input> <textarea id="remark" placeholder="消息备注"></textarea> <input ...

Can two Angular element components be utilized simultaneously on a single page in Angular 6?

Currently, I'm attempting to host independent Angular elements that can be seamlessly integrated into a non-Angular webpage. Everything works perfectly fine when there's only one element on the page, but as soon as I try to load two or more, I en ...

Applying a consistent script with varying inputs on the same HTML page

Is it possible to create a JavaScript code that can be used across different sections of an HTML document? The goal is for the script to fetch data such as title, runtime, and plot from a specific URL request and insert this information into the appropriat ...

Tips for updating the value of an Array of Objects using an array containing the desired string value

I have a scenario where I need to update the 'checked' key value to true for objects in an array based on another array's values. var daysActive = ['monday', 'tuesday', 'wednesday']; var weekDays = [{ "name": ...

"Techniques for incorporating a screen in Angular application (Switching between Edit and View modes) upon user interaction

We are currently working on a screen that requires the following development: This screen will have the following features: When clicking on a button, the fields should become editable. In the image provided, there is some repeated data, but in our case, ...

Effectively handle multiple connections from nodejs to postgres using the pg library

I need to run a script that performs multiple queries using the pg library for managing connections. However, I am facing an issue where my program stops working when the connection pool is full and does not queue future queries. I have tried setting the p ...

Creating a dynamic image binding feature in Angular 8

I am working with an object array that requires me to dynamically add an image icon based on the type of credit card. Typescript file icon: any; savedCreditCard = [ { cardExpiryDateFormat: "05/xx", cardNumberLast: "00xx", cardId: "x ...