Comments (17)
Same issue with angular 7
from generator-angular2-library.
The paths
option in tsconfig.json
worked for me, after futzing around for hours.
"paths": {
"@angular/*": ["../node_modules/@angular/*"]
}
Adding --preserve-symlinks
to the build command, on the other hand, did not work for me.
from generator-angular2-library.
I had the same problem and I removed node_module folder and yarn.lock (or package-lock.json in case u are using npm) and installed dependencies again, now my problem is solved, hope it's helpful
installing dependencies by:
yarn install # or npm install
from generator-angular2-library.
I tired both the above solution, but no success. I am facing following error:
ERROR { Error: StaticInjectorError(AppServerModule)[NgClass -> ElementRef]: StaticInjectorError(Platform: core)[NgClass -> ElementRef]: NullInjectorError: No provider for ElementRef! at NullInjector.module.exports.NullInjector.get ngTempTokenPath: null, ngTokenPath: [ 'NgClass', [Function: ElementRef] ] }
Also, i have upgraded my application from angular5 to angular 6 and trying to implement server-side rendering.
Any solution?
from generator-angular2-library.
Got it working by adding...
"build": {
"preserveSymlinks": true
},
to defaults in .angular-cli.json file
from generator-angular2-library.
Thanks @AchiraFernando, it's working!
from generator-angular2-library.
I'm seeing the same issue with Angular 8:
CardComponent.html:13 ERROR NullInjectorError: StaticInjectorError(AppModule)[LinkDirective -> ElementRef]:
StaticInjectorError(Platform: core)[LinkDirective -> ElementRef]:
NullInjectorError: No provider for ElementRef!
I've tried the following:
- Deleting
node_modules
andpackage-lock.json
and runningnpm install
again. - Adding
"preserveSymlinks": true
tobuild.options
in myangular.json
file. - Updating the
paths
property intsconfig.json
with"@angular/*": ["../node_modules/@angular/*"]
. - Publishing my changes and loading my library from the npm library, instead of loading it locally.
... None of this worked. I can only get my attribute directive to work if I host it inside my project instead of attempting to load it as a third-party library.
I've even tried copying and pasting the attribute directive from the Angular docs as-is, without modifications, and the error still occurs.
I suspect this might be an issue with Angular itself, where attempting to load and use attribute directives from libraries simply doesn't work.
from generator-angular2-library.
"paths": {
"@angular/*": [
"./node_modules/@angular/*"
]
}
Make the paths
mapping in the application's tsconfig (where you are linking to the library) and not the library one.
from generator-angular2-library.
It's relationed to install the library from local dir directly, when I publish the library to NPM and install from npm servers, works perfect
from generator-angular2-library.
Got it working by adding...
"build": { "preserveSymlinks": true },
to defaults in .angular-cli.json file
I think "preserveSymlinks": true
should be in build.options
from generator-angular2-library.
same here, any solution?
from generator-angular2-library.
Can you please post your index.ts or the file containing your @NgModule
from generator-angular2-library.
@izifortune This is the same file created using the cli, no changes
from generator-angular2-library.
As a quick test I simply renamed my directive selector to bsRotate and added it to the component markup. I did not get the error. I got other errors though. I had to restart the playground a few times. I verified the directive was applied.
from generator-angular2-library.
I tried @AchiraFernando's solution and still getting the same error. I'm using Angular 5.2. Any suggestions?
from generator-angular2-library.
Instead of using ElementRef we can use:
import { DOCUMENT } from '@angular/common';
constructor( @Inject(DOCUMENT) private doc ) {}
let [link]: HTMLLinkElement[] = this.doc.querySelectorAll(`[rel="canonical"]`);
from generator-angular2-library.
Instead of using ElementRef we can use:
import { DOCUMENT } from '@angular/common'; constructor( @Inject(DOCUMENT) private doc ) {} let [link]: HTMLLinkElement[] = this.doc.querySelectorAll(`[rel="canonical"]`);
But that assumes you only have a single instance of your component?
from generator-angular2-library.
Related Issues (20)
- Routing with lazy loaded modules, AOT compilation HOT 2
- NullInjectorError: No provider for AlertService!
- "npm run build" fails when source open with Visual Studio Code
- Livereload not working on components in root folder (Angular 5 & Cli 1.7)
- Angular 4
- #260 not resolved HOT 1
- playground doesn't work HOT 3
- Error: Unexpected token <
- Error: StaticInjectorError[SampleService-> HttpClient] HOT 2
- Update to angular 6 HOT 2
- npm ERR! notarget No compatible version found: [email protected]
- How can I route jumps in third-lib packages?
- Some *.ts files are packaged and do not generate *.ts files.
- Wrong filenames in src/package.json?
- gulp error after upgrading to nodejs v10.x and npm v6.4.0 HOT 1
- playground not working with 3rd party library HOT 1
- Could not resolve entry (C:\Users\bhawin.parkeria\Music\datepicker\build/index.js) Starting 'rollup:fesm'
- Update to angular 7
- Angular 8 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from generator-angular2-library.