Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Webpack 网页包未捕获语法错误:意外标记<;_Webpack_Webpack Dev Server - Fatal编程技术网

Webpack 网页包未捕获语法错误:意外标记<;

Webpack 网页包未捕获语法错误:意外标记<;,webpack,webpack-dev-server,Webpack,Webpack Dev Server,当我使用webpack捆绑我的js文件时 首先,当我在cmd上使用npm运行命令webpack时,创建了两个bundle文件,即bundle.js和1.bundle.js。创建2个捆绑包文件是否正常 其次,当我在index.html中使用bundle.js时,它会被加载,1.bundle.js也会被加载到页面上,但是1.bundle.js会被修改成一个带有各种脚本标签的html文件。这也正常吗 第三,它在控制台中显示了一个错误,Uncaugh语法错误:意外的令牌主js文件bundle.js试图从

当我使用webpack捆绑我的js文件时

首先,当我在cmd上使用npm运行命令
webpack
时,创建了两个bundle文件,即
bundle.js
1.bundle.js
。创建2个捆绑包文件是否正常

其次,当我在
index.html
中使用
bundle.js
时,它会被加载,
1.bundle.js
也会被加载到页面上,但是
1.bundle.js
会被修改成一个带有各种脚本标签的html文件。这也正常吗


第三,它在控制台中显示了一个错误,
Uncaugh语法错误:意外的令牌主js文件
bundle.js
试图从以这种方式生成的url请求块:

script.src = __webpack_require__.p + "" + chunkId + ".bundle.js";
其中
\uuuu webpack\u require\uuu.p
是webpack公共路径

这意味着块将从相对于文档的路径(
/websites/t3/node/
)加载。但由于您的文件位于
/websites/t3/iflychat app/require/
中,因此无法正确加载块

所以,解决方案是指定js资产的正确路径:

module.exports = {
  ...
  output: {
    path: path.resolve('./dist'),
    publicPath: '/websites/t3/iflychat-app/require/',
    filename: 'bundle.js'
  },
  ...
}

请提供您的webpack config.added
webpack.config
文件
bundle.js
请求自
[site]/websites/t3/iflychat app/require/bundle.js
[site]/websites/t3/node/1.bundle.js
,因此,该文件找不到,而那些
只是Drupal 404页面。你需要在
输出
部分指定
公共路径
,并使用值
/websites/t3/iflychat app/require/
你是最好的伙伴,你知道我欠你一个比萨饼。现在开始工作了。谢谢你的帮助,伙计。也许你可以把它写在回答里,我会接受的。从现在起,我被困在上面大约5个小时了
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN"
  "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" version="XHTML+RDFa 1.0" dir="ltr"
  xmlns:content="http://purl.org/rss/1.0/modules/content/"
  xmlns:dc="http://purl.org/dc/terms/"
  xmlns:foaf="http://xmlns.com/foaf/0.1/"
  xmlns:og="http://ogp.me/ns#"
  xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
  xmlns:sioc="http://rdfs.org/sioc/ns#"
  xmlns:sioct="http://rdfs.org/sioc/types#"
  xmlns:skos="http://www.w3.org/2004/02/skos/core#"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema#">

<head profile="http://www.w3.org/1999/xhtml/vocab">
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" href="http://web.iflychatdev.com:12000/websites/t3/misc/favicon.ico" type="image/vnd.microsoft.icon" />
<link rel="shortlink" href="/websites/t3/node/1" />
<link rel="canonical" href="/websites/t3/node/1" />
<meta name="Generator" content="Drupal 7 (http://drupal.org)" />
  <title>iflychat-require-app | T3</title>
  <style type="text/css" media="all">
</style>
<style type="text/css" media="all">
</style>
<style type="text/css" media="all">

</style>
<style type="text/css" media="all">
@import 

...etc
var path = require('path');

module.exports = {
  //our config
  context: path.resolve(__dirname, 'require'),
  entry: './iflychat-main',
  output: {
    path: path.resolve('./dist'),
    filename: 'bundle.js'
  },
  resolve: {
    modulesDirectories: ['.','./require/libs'],
  },
}
script.src = __webpack_require__.p + "" + chunkId + ".bundle.js";
module.exports = {
  ...
  output: {
    path: path.resolve('./dist'),
    publicPath: '/websites/t3/iflychat-app/require/',
    filename: 'bundle.js'
  },
  ...
}