VS2017 .NET Core 2.0 React App在使用0x800a1391的JSX'import'语句上失败 - JavaScript运行时错误:'require'未定义 [英] VS2017 .NET Core 2.0 React App Fails on JSX 'import' statement with 0x800a1391 - JavaScript runtime error: 'require' is undefined

查看:205
本文介绍了VS2017 .NET Core 2.0 React App在使用0x800a1391的JSX'import'语句上失败 - JavaScript运行时错误:'require'未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用新项目ASP .NET Core Web Application创建了一个.NET Core 2.0 React App,然后选择React.JS作为模板。  ;我添加了一些控制器和一些视图。 然后我添加了一些JSX脚本并从我的视图中调用它们。 麻烦
,当我运行JSX文件行...

I created a .NET Core 2.0 React App using the new project, ASP .NET Core Web Application and then choosing React.JS as the template.  I added some controllers and some views.  I then added some JSX scripts and called them from my views.  Trouble is, when I run it the JSX file line...

i mport * as来自'react'的反应;

引发错误......

Throws the error...

0x800a1391 - JavaScript运行时错误:'require'未定义

0x800a1391 - JavaScript runtime error: 'require' is undefined

我尝试使用NPM(也安装了Node.JS)下载babel核心和加载程序包,但这似乎没有帮助。

I tried downloading the babel core and loader packages using NPM (also installed Node.JS) but that doesn't seem to help.

我怀疑这是webpack配置文件的一个问题,但是为什么模板默认情况下不能导入模块。 此外,这似乎在Chrome中有所作为,虽然Chrome中还有另一个问题,但我在Chome
没有断点得到尊重所以我也有点搞砸了。加上它非常慢。

I suspect this is an issue with the webpack config file, but why on earth would the template not facilitate being able to import the modules by default.  Also, this seems to work in Chrome somewhat, though there is another issue in Chrome but I in Chome no breakpoint get honored so I'm a little screwed there too. Plus it's terribly slow.

任何指针都会受到赞赏。

Any pointers would be appreciated.

谢谢!

推荐答案

您需要包含  < a href ="http://requirejs.org/"rel ="nofollow"style ="margin:0px; padding:0px; border:0px; font-size:15px; line-height:inherit; font-family:Arial ,'Helvetica Neue',Helvetica,sans-serif; vertical-align:baseline; color:#005999"> requirejs  或
捆绑您的脚本 
n pm
TypeScript提供模块语法并编译为 
require  调用,
但不提供运行时模块 
loader
您必须在页面中包含该脚本才能使脚本生效。
You need to include requirejs or bundle your scripts with npm. TypeScript provides the module syntax and compiles down into require calls, but does not provide a runtime module loader. You must include that in your page for the scripts to work.


这篇关于VS2017 .NET Core 2.0 React App在使用0x800a1391的JSX'import'语句上失败 - JavaScript运行时错误:'require'未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆