Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find module '@angular/elements' : Angular 7

I am new to angular right now angular 7 using.I want to create angular elements so importing import { createCustomElement } from '@angular/elements' but it giving error Cannot find module '@angular/elements'. Any help will helpful.

like image 279
Raj Avatar asked Nov 15 '18 06:11

Raj


People also ask

How to fix Cannot find module in Angular?

To solve the error "Cannot find module '@angular/core'", make sure you have installed all dependencies by running the npm install command, set the baseUrl option to src in your tsconfig. json file and restart your IDE and development server. Copied!

How can I use Angular element in another Angular project?

In order to use it in another Angular app, we don't really need to build the component; as it is a simple Angular component, we can just import and use it. But if we only have access to compiled files, we can include them with the scripts field in our angular.

What is custom element in Angular?

A custom element hosts an Angular component, providing a bridge between the data and logic defined in the component and standard DOM APIs. Component properties and logic maps directly into HTML attributes and the browser's event system.


2 Answers

You have probably not installed @angular/elements. Please install it.

Run npm install @angular/elements

like image 65
Amit Chigadani Avatar answered Oct 08 '22 17:10

Amit Chigadani


Another alternative

ng add @angular/elements --project=*your_project_name*
like image 31
Qin Chenfeng Avatar answered Oct 08 '22 19:10

Qin Chenfeng