Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/471.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
Javascript index.js:1未捕获的语法错误:意外标记<;_Javascript_Html_Node.js_Reactjs - Fatal编程技术网

Javascript index.js:1未捕获的语法错误:意外标记<;

Javascript index.js:1未捕获的语法错误:意外标记<;,javascript,html,node.js,reactjs,Javascript,Html,Node.js,Reactjs,我正在尝试在IIS服务器上运行我们的web应用程序的生产版,该应用程序使用React的缩小版(生产版)。我们目前可以运行开发人员版本,但是当尝试运行构建版本时,我们不断得到以下错误 `index.js:1 Uncaught SyntaxError: Unexpected token <` 检查您的页面,并验证在获取index.js文件时,您是否实际获得了该文件。我的猜测是,当您获取index.js时,您实际上会获得index.html,因此当您的浏览器尝试将index.html文件的副

我正在尝试在IIS服务器上运行我们的web应用程序的生产版,该应用程序使用React的缩小版(生产版)。我们目前可以运行开发人员版本,但是当尝试运行构建版本时,我们不断得到以下错误

`index.js:1 Uncaught SyntaxError: Unexpected token <` 

检查您的页面,并验证在获取index.js文件时,您是否实际获得了该文件。我的猜测是,当您获取index.js时,您实际上会获得index.html,因此当您的浏览器尝试将index.html文件的副本作为脚本执行时,它会立即出错,因为<不是javascript的有效初始字符。这是人们在配置html推送状态时遇到的常见错误配置,因此您的Web服务器可能未正确配置为正确服务index.js;确保在
iisconfig.xml
文件中设置了以下内容:

<configuration>
    <system.webServer>
        <rewrite>
          <rules>
            <rule name="Main Rule" stopProcessing="true">
                    <match url=".*" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="/" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>


您是否在
index.js
中使用任何JSX?您是否尝试过直接在浏览器中打开
index.js
并检查输出?没有jsx,index.js文件目前只是一个警报功能,仅用于故障排除。浏览器中index.js文件的输出是有效的,打开控制台并转到Sources选项卡(假设是Chrome)。在那里找到
index.js
,看看浏览器在里面声称什么。这可能像缓存问题一样简单。我将发布我的开发控制台打印输出。您提供的代码与问题并不完全相关。那么如何解决此问题呢?请编辑您的答案,以包含相关信息,而不是编写注释。
<configuration>
    <system.webServer>
        <rewrite>
          <rules>
            <rule name="Main Rule" stopProcessing="true">
                    <match url=".*" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="/" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>