javascript - 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
解决方案
将文件名更改为 webpack.config.js(不是 .json)
推荐阅读
- java - Android中没有预期的输出
- javascript - 点击事件不适用于仅使用 Javascript 的轮播
- docker - Hortonworks HDP docker如何公开端口
- typescript - Typescript 中的动态键
- python - 无法从外部应用程序发送 JSON,但我的 Django 测试有效
- python - 删除 XML 声明标记的 Python 代码
- asp.net - Razor 和 MVC 页面的 Asp.net Core 应用程序问题
- c - 相同的 C 程序但不同的执行时间
- ios - XCode 调试器不会显示所有变量内容。它是一个错误吗?
- postgresql - 在更新我们读取的行时从 Postgres 只读副本进行缓慢的批量读取