首页 > 解决方案 > Unexpected token m in JSON at position 0 for cloud 9.io

问题描述

I'm new to coding and I'm trying to do what the lecturer is doing. We're looking at webpacks but everytime I try to use the command "npx webpack" it comes up with /home/ubuntu/workspace/assignment1/hellowp/webpack.config.json: Unexpected token m in JSON at position 0"

How do I fix this?

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

package.json:

{
  "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"
  }
}

app.js

import $ from "jquery";

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

  <div id = 'intro'></p>
  <script src='./dist/app.bundle.js'></script>
  
  //whats in my html

标签: javascriptjquerycssjsonsyntax

解决方案


将文件名更改为 webpack.config.js(不是 .json)


推荐阅读