Aspnetcore: Error: Cannot find module "./components/api-authorization/Login" in React app with authentication in ASP.NET Core 3 Preview 3

Created on 7 Mar 2019  Â·  7Comments  Â·  Source: dotnet/aspnetcore

Describe the bug

Another error occurs as soon as you start an app created using the React app template with authentication.

To Reproduce

  1. Follow the steps in issue #8281
  2. Fix that error by changing = to : in ApiAuthorizationConstants.js
  3. See another error:
×
Error: Cannot find module "./components/api-authorization/Login"
â–¼ 13 stack frames were expanded.
./src/components/api-authorization/ApiAuthorizationRoutes.js
https://localhost:44315/static/js/bundle.js:53166:7
__webpack_require__
C:/W ork/Play/ReactTest1/ClientApp/webpack/bootstrap 43633f0e2b726d97cc14:678
fn
C:/W ork/Play/ReactTest1/ClientApp/webpack/bootstrap 43633f0e2b726d97cc14:88
./src/App.js
https://localhost:44315/static/js/bundle.js:51925:111
__webpack_require__
C:/W ork/Play/ReactTest1/ClientApp/webpack/bootstrap 43633f0e2b726d97cc14:678
fn
C:/W ork/Play/ReactTest1/ClientApp/webpack/bootstrap 43633f0e2b726d97cc14:88
./src/index.js
https://localhost:44315/static/js/bundle.js:54708:63
__webpack_require__
C:/W ork/Play/ReactTest1/ClientApp/webpack/bootstrap 43633f0e2b726d97cc14:678
fn
C:/W ork/Play/ReactTest1/ClientApp/webpack/bootstrap 43633f0e2b726d97cc14:88
0
https://localhost:44315/static/js/bundle.js:54860:18
__webpack_require__
C:/W ork/Play/ReactTest1/ClientApp/webpack/bootstrap 43633f0e2b726d97cc14:678
(anonymous function)
C:/W ork/Play/ReactTest1/ClientApp/webpack/bootstrap 43633f0e2b726d97cc14:724
(anonymous function)
https://localhost:44315/static/js/bundle.js:728:10

Expected behavior

No error

area-identity identity-service investigate

Most helpful comment

To fix this error change the content of the ApiAuthorizationRoutes.js file
from
import { Login } from './components/api-authorization/login'
import { Logout } from './components/api-authorization/Logout'
to
import { Login } from './Login'
import { Logout } from './Logout'

And change the content of ApiAuthorizationConstants.js file
from
ApiAuthorizationPrefix = prefix,
to
ApiAuthorizationPrefix: prefix,

@mkArtakMSFT @javiercn

All 7 comments

@javiercn

@javiercn, can you please look into this, as this seems to be related to the new SPA templates area.

Is there a known workaround for this? It may well be very simple, but I'm completely new to React (and to ASP.NET Core, for that matter).

To fix this error change the content of the ApiAuthorizationRoutes.js file
from
import { Login } from './components/api-authorization/login'
import { Logout } from './components/api-authorization/Logout'
to
import { Login } from './Login'
import { Logout } from './Logout'

And change the content of ApiAuthorizationConstants.js file
from
ApiAuthorizationPrefix = prefix,
to
ApiAuthorizationPrefix: prefix,

@mkArtakMSFT @javiercn

Thanks, that works! ESLint also complains about missing semicolons on those lines, by the way.

This is a known issue. Take a look at the list of known issues for more details:

https://github.com/dotnet/core/blob/master/release-notes/3.0/preview/3.0.0-preview-known-issues.md

This is fixed now

Was this page helpful?
0 / 5 - 0 ratings

Related issues

markrendle picture markrendle  Â·  3Comments

githubgitgit picture githubgitgit  Â·  3Comments

farhadibehnam picture farhadibehnam  Â·  3Comments

BrennanConroy picture BrennanConroy  Â·  3Comments

Kevenvz picture Kevenvz  Â·  3Comments