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

Angular cli 5 AOT gives Module not found can't resolve .ngfactory #285

Closed
ghost opened this issue Nov 16, 2017 · 8 comments · Fixed by #2051
Closed

Angular cli 5 AOT gives Module not found can't resolve .ngfactory #285

ghost opened this issue Nov 16, 2017 · 8 comments · Fixed by #2051
Labels

Comments

@ghost
Copy link

ghost commented Nov 16, 2017

Type of Issue

[X] Bug Report
[ ] Feature Request

Description

When building bundle with ng-packagr, installing it in Angular 5 app and then trying to AOT the application, the compiler throws the error that it's not able to find the referenced module.

How To Reproduce

  1. "ng-packagr -p ng-package.json" bundle and npm publish
  2. Install on new Angular 5 app (i.e. npm install)
  3. Using ngTools webpack 1.8.0 AOT the application
  4. Get errror. Example:
    image

Expected Behaviour

Should not display message since bundle is already build

Version Information

ng-packagr: v2.0.0-rc.0
node: v8.8.1
@angular: v5.0.1
rxjs: v5.5.2
zone.js: v0.8.18
typescript: v2.6.1

Workaround:
angular/angular-cli#8284 (comment)

Which is to include the library in the Include files of the tsconfig compilation

@macjohnny
Copy link
Contributor

removing "rootDir": "./src", from the tsconfig.json resolved the problem for us

@macjohnny
Copy link
Contributor

macjohnny commented Nov 17, 2017

we also have a similar issue with angular 4, which we weren't able to resolve, yet.
we used a completely fresh angular cli generated app:

mkdir test4
cd test4
npm install @angular/cli@1.4.9
 ng new test4dummy --routing

 cd test4dummy
 npm install --save my-library

@macjohnny
Copy link
Contributor

apparently, angular5 library builds are not compatible with angular4, see angular/angular#19607

@dherges
Copy link
Contributor

dherges commented Nov 17, 2017

Please check your typescript version! You say you use typescript: v2.6.1

There are known issues with that in Angular. For Angular v4, please use a TypeScript 2.3.x. For Angular v5, please use a TypeScript v2.4.x.

See https://github.com/angular/angular-cli/blob/ae53cb1319a2ef3b687cc0eeabb371ff5c048af0/packages/%40angular/cli/upgrade/version.ts#L170-L172

See #236

@nweldev
Copy link
Contributor

nweldev commented Apr 24, 2018

I encountered this issue this day after a big refactoring, with TS 2.6 and the latest builds of angular-cli, devkit and ng-packagr.

It simply was a issue with some remaining imports from the wrong files. #285 (comment) seems to be related to that, as it leads, by another way, to wrong imports too.

I don't think this issue is directly related to ng-packagr. Only the ngc error message is misleading.

@steveTripactions
Copy link

Ran into this error using a local npm group like @myorg. After much searching it turns out *.metadata.json in node_modules has the wrong "importAs" making ng serve --aot fail compilation. The fix is it has to be @myorg/mylibrary and this was being set from the field "name": "@myorg/mylibrary" in projects/mylibrary/package.json.

@raphael22
Copy link

raphael22 commented Apr 4, 2019

Be careful to node_modules folder depth too.
Import from '@xxx/yyy' will work but not from '@xxx/yyy/zzz'
Even if you make sure metadata.json get the right path.

EDIT: Actually you can but your package.json name must reflect your directory
ex:

{
   "name": "@domain/shared/api"
}
-node_modules
  -@domain
    -shared
      -api
        -index.ts

alan-agius4 added a commit that referenced this issue Aug 20, 2021
With this change we enabled publishing of Ivy partially compiled libraries by default.

BREAKING CHANGE: Compilation of libraries using VIew Engine is no longer supported.

Closes #1087, closes #382, closes #285, closes #317, closes #355, closes #656, closes #917
@github-actions
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

This action has been performed automatically by a bot.

@github-actions github-actions bot locked and limited conversation to collaborators Sep 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging a pull request may close this issue.

5 participants