x)- [x ] bug report -> please search issues before submitting
- [ ] feature request
Node v10.2.1
NPM 6.1.0
macOS High Sierra
ng new ng-shared
cd ng-shared
ng generate library shared
ng build shared
import in app.module.ts and add to imports
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { SharedModule } from 'shared';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
SharedModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
Works fine.
The issue is when I try and npm install or npm link this to another project. Within the same directory ng-shared is now in. (sibling directory to ng-shared)
ng new ng-project
cd ng-project
npm install ../ng-shared/dist/shared/
(I've also tried with npm link)
Add to app.module.ts just like before but in this project.
and then:
ng serve
Only messages are warnings:
```WARNING in ../ng-shared/node_modules/@angular/core/fesm5/core.js
4826:15-36 Critical dependency: the request of a dependency is an expression
WARNING in ../ng-shared/node_modules/@angular/core/fesm5/core.js
4838:15-102 Critical dependency: the request of a dependency is an expression ï½¢wdmï½£: Compiled with warnings.
But I get this error in the browser console:
Error: StaticInjectorError(AppModule)[LocationStrategy -> PlatformLocation]:
StaticInjectorError(Platform: core)[LocationStrategy -> PlatformLocation]:
NullInjectorError: No provider for PlatformLocation!
at NullInjector.push../node_modules/@angular/core/fesm5/core.js.NullInjector.get (core.js:951)
at resolveToken (core.js:1195)
at tryResolveToken (core.js:1140)
at StaticInjector.push../node_modules/@angular/core/fesm5/core.js.StaticInjector.get (core.js:1035)
at resolveToken (core.js:1195)
at tryResolveToken (core.js:1140)
at StaticInjector.push../node_modules/@angular/core/fesm5/core.js.StaticInjector.get (core.js:1035)
at resolveNgModuleDep (core.js:8071)
at _callFactory (core.js:8139)
at _createProviderInstance$1 (core.js:8091)
```
I would like it work the same way as when you use the library within the project you generated it from, and if you were to install it as a published npm. For example I copied the shared directory into node_modules and it works perfectly.
Does the CLI have an issue with symlinks?
This issue looks very similar to https://github.com/angular/angular-cli/issues/10980.
Thank you! Knew it'd be simples. I kept bumping into the preserveSymlink property but everywhere I tried it didn't work.
angular.json(within the project I'm trying to install the library in)
"projects": {
"ng-project": {
"architect": {
"build": {
"options": {
"preserveSymlinks": true
That did it.
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._
Most helpful comment
Thank you! Knew it'd be simples. I kept bumping into the
preserveSymlinkproperty but everywhere I tried it didn't work.angular.json(within the project I'm trying to install the library in)
That did it.