How do I create a component in Angular 2 that impo

2019-06-27 04:01发布

I am fairly new to Angular 2 and TypeScript. I am using AngularCLI and NPM to create my Angular Project. I have used NPM to install the quill node module into my project. I am now trying to create a component in which I can customize my quill editor through their API.

I am trying to use:

import * as Quill from 'quill'; 

This is returning a 'cannot find quill module' error.

I have already added

"": "0.0.26",
"quill": "^1.0.4",

to package.json as dependencies.

1条回答
老娘就宠你
2楼-- · 2019-06-27 04:42

I tried to reproduce your issue in a pet Angular CLI project generated with the ng new command, and it worked fine. Here is the code:

import { Component } from '@angular/core';
import * as Quill from 'quill';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'app works!';

  ngOnInit() {
    console.log(Quill);
  }
}
And here's the output I get: Image Link

Go to you project's node_modules folder and look for a folder named quill, anyway, even if it is there, delete the node_modules folder and run npm i command again

查看更多
登录 后发表回答