简体   繁体   English

我不能让这个简单的代码运行 webpack

[英]i can't make works this easy code to run webpack

i learn how to use webpack.我学习如何使用 webpack。 I wrote this code in my webpack.config.js我在我的 webpack.config.js 中写了这段代码

const path= require('path')

module.exports= {
    entry:'./app/assets/scripts/App.js',
    output: {
        filename:'bundled.js',
        path: path.resolve(__dirname,'App')
    },
    mode:'development',
    watch: true, 
};

I wrote this code in my package.json我在我的 package.json 中写了这段代码

 { 
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "dev": "webpack",
    "test": "echo \"Error: no test specified\" && exit 1"
 },
 "devDependencies":{
    "webpack": "^4.41.0",
    "webpack-cli": "^3.3.9",
    "webpack-dev-server": "^3.9.0"
 }

and this is the code in my App.js这是我的 App.js 中的代码

alert("Hello, this is just a test!");

i run npm run dev .我运行npm run dev i get no errors messages, but the javascript don't run in my index page.我没有收到任何错误消息,但 javascript 没有在我的索引页面中运行。 Please help me, i don't understand from where the problem comes.请帮助我,我不明白问题出在哪里。

after hours of trying, it seems my index.html VisualCodeStudio started to now that bundled.js exist in proposing it via intellisens.经过数小时的尝试,似乎我的 index.html VisualCodeStudio 开始到现在 bundled.js 存在于通过 intellisens 提出它。 I delete also the main: index.js on my package.json.我还删除了 package.json 上的 main: index.js。 Now its working, even if i didnt't yet clearly detected what was the problem initially.现在它的工作,即使我还没有清楚地发现最初的问题是什么。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM