VS2017 .NET Core 2.0 React App Fails on JSX 'import' statement with 0x800a1391 - JavaScript runtime error: 'require' is undefined RRS feed

  • Question

  • Hi,

    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...

    import * as React from 'react';

    Throws the error...

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

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

    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.


    Sunday, February 18, 2018 3:28 AM

All replies

  • 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.

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (kokkisajee) or Facebook (sajeetharan) profile for Sajeetharan at Stack Overflow, Q&A for professional and enthusiast programmers

    • Proposed as answer by Judy ZhuY Tuesday, February 20, 2018 4:57 AM
    Sunday, February 18, 2018 3:32 AM
  • Hi rprice70,

    Welcome to the MSDN forum.

    This forum is discussing Visual Studio WPF/SL Designer, Visual Studio Guidance Automation Toolkit, Developer Documentation and Help System, and Visual Studio Editor.

    According to your description, your issue is related to ASP.NET Core develop, I suggest you repost a new thread to the following forum for a professional answer.


    Thanks for your understanding.



    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, February 19, 2018 7:23 AM