Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add universal Server Side Rendering error Module file (/src/@app/app.module.ts) not found #472

Closed
1 of 3 tasks
manzapanza opened this issue May 20, 2019 · 6 comments
Closed
1 of 3 tasks
Labels
wrong repo Wrong repository for this issue

Comments

@manzapanza
Copy link

manzapanza commented May 20, 2019

I'm submitting a...

  • Bug report
  • Feature request
  • Documentation issue or request

Current behavior

I'm follow the documentation to add universal server side rendering to the project:

Running the command:

ng add @nguniversal/express-engine --clientProject my-project-name

The command install the package @nguniversal/express-engine but after that I get this error:

Module file (/src/@app/app.module.ts) not found

I tried also with a fresh new generated project with the version 6.1.0, but I get the same error.

Expected behavior

This command should install the package @nguniversal/express-engine and edit the project adding some new files and editing some others.. something like that:

Installed packages for tooling via npm.
CREATE src/main.server.ts (220 bytes)
CREATE src/app/app.server.module.ts (427 bytes)
CREATE src/tsconfig.server.json (219 bytes)
CREATE webpack.server.config.js (1360 bytes)
CREATE server.ts (1472 bytes)
UPDATE package.json (1874 bytes)
UPDATE angular.json (4499 bytes)
UPDATE src/main.ts (432 bytes)
UPDATE src/app/app.module.ts (438 bytes)

Minimal reproduction of the problem with instructions

mkdir my-project-name && cd $_
ngx new
...
// follow the wizard choosing any options and create the project.
// After that run:
...
ng add @nguniversal/express-engine --clientProject my-project-name
Installed packages for tooling via npm.
Module file (/src/@app/app.module.ts) not found

Environment

- generator version: 6.1.0
- node version: 10.4.1
- npm version: 6.1.0
- OS:  Mac
@sinedied
Copy link
Member

Seems more like a ng-cli issue with that particular generator that our own, as the expected path (/src/@app) vs (src/app) is not derived properly from angular.json config.

If it's just a path (app vs @app) issue, that could be an easy fix we can do anyways.

See also #230 for reference as Angular universal may not be supported yet.

@benja-admin
Copy link

"If it's just a path (app vs @app) issue, that could be an easy fix we can do anyways."

This is exactly what my issue is. Did we have a resolution on this?

@sinedied
Copy link
Member

I tried with a plain app coming from ng new and they have the exact same path structure.

Seems to me that the problems comes from the @nguniversal/express-engine schematics that do not properly takes in account the typescript path alias @app set in tsconfig.json, causing this failure. Unfortunately, I see nothing that we can do on our side, you should try posting this issue to the @nguniversal/express-engine repo.

In the meantime, you can try substituting @app/ imports in your apps with full absolute paths (ie /src/app) and remove the alias from tsconfig.json.

@imomin
Copy link

imomin commented Jul 17, 2019

I updated import { AppModule } from '@app/app.module'; to import { AppModule } from './app/app.module'; in my main.ts.
After install, I switched it back.

@reza-iranmanesh
Copy link

reza-iranmanesh commented Aug 12, 2019

I had a very similar problem, documented here and @imomin 's answer worked.

@sinedied
Copy link
Member

Closing as the issue should be moved to @nguniversal/express-engine repo.

@sinedied sinedied added the wrong repo Wrong repository for this issue label Mar 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wrong repo Wrong repository for this issue
Projects
None yet
Development

No branches or pull requests

5 participants