title: Error using ng-packagr : Module not found: Error: Can't resolve
body: <p>I am unable to import the component defined in one of the sub module which I am packaging and referring in main project. Everything seems fine but I still see an error -</p>
  
  <blockquote>
    <p>ERROR in ./src/app/app.module.ts Module not found: Error: Can't
    resolve '@first-project/second-project/app/regist
    ration/registration.component' in
    'C:\Users\anujin\Documents\workspace-vs-code\ FirstProject\src\app'
    ERROR in ./src/app/app-routing.module.ts Module not found: Error:
    Can't resolve '@first-project/second-project/app/regist
    ration/registration.component' in
    'C:\Users\anujin\Documents\workspace-vs-code\ FirstProject\src\app'</p>
  </blockquote>
  
  <p>I created two projects -</p>
  
  <ul>
  <li>FirstProject </li>
  <li>SecondProject</li>
  </ul>
  
  <p>I created a <code>RegistrationComponent</code> in <code>SecondProject</code> which I need to use in <code>FirstProject</code>.</p>
  
  <p><strong>FirstProject files :</strong> </p>
  
  <p><code>package.json</code></p>
  
  <pre><code>{
    "name": "@first-project/second-project",
    "version": "0.0.0",
    "scripts": {
      "ng": "ng",
      "start": "ng serve",
      "build": "ng build",
      "test": "ng test",
      "lint": "ng lint",
      "e2e": "ng e2e",
      "packagr": "ng-packagr -p ng-package.json"
    },
    "private": true,
    "dependencies": {
      "@angular/animations": "~7.2.0",
      "@angular/common": "~7.2.0",
      "@angular/compiler": "~7.2.0",
      "@angular/core": "~7.2.0",
      "@angular/forms": "~7.2.0",
      "@angular/platform-browser": "~7.2.0",
      "@angular/platform-browser-dynamic": "~7.2.0",
      "@angular/router": "~7.2.0",
      "core-js": "^2.5.4",
      "ng-packagr": "^4.7.0",
      "rxjs": "~6.3.3",
      "tsickle": "^0.34.3",
      "tslib": "^1.9.0",
      "zone.js": "~0.8.26"
    },
    "devDependencies": {
      "@angular-devkit/build-angular": "~0.13.0",
      "@angular/cli": "~7.3.1",
      "@angular/compiler-cli": "~7.2.0",
      "@angular/language-service": "~7.2.0",
      "@types/node": "~8.9.4",
      "@types/jasmine": "~2.8.8",
      "@types/jasminewd2": "~2.0.3",
      "codelyzer": "~4.5.0",
      "jasmine-core": "~2.99.1",
      "jasmine-spec-reporter": "~4.2.1",
      "karma": "~3.1.1",
      "karma-chrome-launcher": "~2.2.0",
      "karma-coverage-istanbul-reporter": "~2.0.1",
      "karma-jasmine": "~1.1.2",
      "karma-jasmine-html-reporter": "^0.2.2",
      "protractor": "~5.4.0",
      "ts-node": "~7.0.0",
      "tslint": "~5.11.0",
      "typescript": "~3.2.2"
    }
  }
  </code></pre>
  
  <p><code>ng-package.json</code> -</p>
  
  <pre><code>{
      "$schema": "./node_modules/ng-packagr/package.schema.json",
      "lib": {
          "entryFile": "./src/public_api.ts"
      },
      "whitelistedNonPeerDependencies": [
          "@angular/animations",
          "@angular/cdk",
          "@angular/common",
          "@angular/compiler",
          "@angular/forms",
          "@angular/core",
          "@angular/http",
          "@angular/material",
          "@angular/platform-browser",
          "@angular/platform-browser-dynamic",
          "@angular/router",
          "core-js",
          "rxjs",
          "tsickle",
          "zone.js",
          "ng-packagr"
        ]
  }
  </code></pre>
  
  <p><code>public_api.ts</code></p>
  
  <pre><code>export * from './app/app.module';
  export * from './app/registration/registration.component';
  </code></pre>
  
  <p>I ran the following commands in <code>FirstProject</code> - </p>
  
  <ul>
  <li>npm run packagr </li>
  <li>cd dist </li>
  <li>npm pack</li>
  </ul>
  
  <p>Then I referred the packaged <code>SecondProject</code> in <code>FirstProject</code>.</p>
  
  <p><strong>FirstProject files -</strong> </p>
  
  <p><code>package.json</code></p>
  
  <pre><code>{
    "name": "first-project",
    "version": "0.0.0",
    "scripts": {
      "ng": "ng",
      "start": "ng serve",
      "build": "ng build",
      "test": "ng test",
      "lint": "ng lint",
      "e2e": "ng e2e"
    },
    "private": true,
    "dependencies": {
      "@angular/animations": "~7.2.0",
      "@angular/cdk": "~7.3.1",
      "@angular/common": "~7.2.0",
      "@angular/compiler": "~7.2.0",
      "@angular/core": "~7.2.0",
      "@angular/forms": "~7.2.0",
      "@angular/material": "^7.3.1",
      "@angular/platform-browser": "~7.2.0",
      "@angular/platform-browser-dynamic": "~7.2.0",
      "@angular/router": "~7.2.0",
      "core-js": "^2.5.4",
      "hammerjs": "^2.0.8",
      "rxjs": "~6.3.3",
      "tslib": "^1.9.0",
      "zone.js": "~0.8.26",
      "@first-project/second-project": "&lt;path&gt;/SecondProject/dist/first-project-second-project-0.0.0.tgz"
    },
    "devDependencies": {
      "@angular-devkit/build-angular": "~0.13.0",
      "@angular/cli": "~7.3.1",
      "@angular/compiler-cli": "~7.2.0",
      "@angular/language-service": "~7.2.0",
      "@types/node": "~8.9.4",
      "@types/jasmine": "~2.8.8",
      "@types/jasminewd2": "~2.0.3",
      "codelyzer": "~4.5.0",
      "jasmine-core": "~2.99.1",
      "jasmine-spec-reporter": "~4.2.1",
      "karma": "~3.1.1",
      "karma-chrome-launcher": "~2.2.0",
      "karma-coverage-istanbul-reporter": "~2.0.1",
      "karma-jasmine": "~1.1.2",
      "karma-jasmine-html-reporter": "^0.2.2",
      "protractor": "~5.4.0",
      "ts-node": "~7.0.0",
      "tslint": "~5.11.0",
      "typescript": "~3.2.2"
    }
  }
  </code></pre>
  
  <p><code>app.module.ts</code></p>
  
  <pre><code>import { BrowserModule } from '@angular/platform-browser';
  import { NgModule } from '@angular/core';
  
  import { AppRoutingModule } from './app-routing.module';
  import { AppComponent } from './app.component';
  import { RegistrationComponent } from '@first-project/second-project/app/registration/registration.component';
  import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
  
  
  @NgModule({
    declarations: [
      AppComponent,
      RegistrationComponent
    ],
    imports: [
      BrowserModule,
      AppRoutingModule,
      BrowserAnimationsModule
    ],
    providers: [],
    bootstrap: [AppComponent]
  })
  export class AppModule { }
  </code></pre>
  
  <p><code>app.routing.ts</code></p>
  
  <pre><code>import { NgModule } from '@angular/core';
  import { Routes, RouterModule } from '@angular/router';
  import { RegistrationComponent } from '@first-project/second-project/app/registration/registration.component';
  
  const routes: Routes = [
    {path: 'registration', component: RegistrationComponent}
  ];
  
  @NgModule({
    imports: [RouterModule.forRoot(routes)],
    exports: [RouterModule]
  })
  export class AppRoutingModule { }
  </code></pre>
  
  <p>I did <code>npm install</code> in <code>FirstProject</code> and I see the reference under node modules created properly, but I do <code>npm start</code> here in <code>FirstProject</code>, it gives the following error -</p>
  
  <blockquote>
    <p>ERROR in ./src/app/app.module.ts
        Module not found: Error: Can't resolve '@first-project/second-project/app/regist
        ration/registration.component' in 'C:\Users\anujin\Documents\workspace-vs-code\
        FirstProject\src\app'
        ERROR in ./src/app/app-routing.module.ts
        Module not found: Error: Can't resolve '@first-project/second-project/app/regist
        ration/registration.component' in 'C:\Users\anujin\Documents\workspace-vs-code\
        FirstProject\src\app'</p>
  </blockquote>
  
  <p>I am unable to understand as what am I missing here.</p>