Problems with the package @types/ckeditor

Encountering some difficulties while utilizing @types/ckeditor from the provided source.

https://www.npmjs.com/package/@types/ckeditor

The installation of the package was successful, and after importing the type into the necessary file, everything appears correct in VS code.

import "CKEDITOR";
import { Injectable } from '@angular/core';

export interface IEditor {
    editor: CKEDITOR.editor
    addEventHandler(eventName: string, onEvent: Function): void;
    addContextMenuItem(menulabel: string, onEvent: Function): void;
    getTrackingPlugin(): any;
}
@Injectable({
    providedIn: 'root'
})

export class Editor implements IEditor {
  public editor: CKEDITOR.editor

  constructor(rootElement: HTMLElement, config: CKEDITOR.config) {
      this.editor = CKEDITOR.inline(rootElement, config);
  }
}

Although everything seems fine, upon building, the following error is displayed.

ERROR in ./src/app/modules/single-editor/services/editor.service.ts
Module not found: Error: Can't resolve 'CKEDITOR' in 'C:\Code\***\src\web\src\app\modules\single-editor\services'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="295e4c4b691907190719">[email protected]</a> build: `ng build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5126343311617f617f61">[email protected]</a> build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\***\AppData\Roaming\npm-cache\_logs\2019-05-07T10_31_08_926Z-debug.log
The terminal process terminated with exit code: 1

Terminal will be reused by tasks, press any key to close it.

The above code is contained within its own module, the Angular version being used is up-to-date, and ckeditor 4 is in use.

Answer №1

After some investigation, I have come across the solution. In order to resolve the issue, it was crucial to add the following piece of code.

/// <reference types="@types/ckeditor" /> 

Although I had attempted this previously without success, the critical error I made was not placing it at the very start of the file. This step is essential for it to work correctly.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Guide to Generating a Compilation Error with Method Decorators in Typescript

Currently, I am developing a library named expresskit which allows the use of decorators to define routes, params, and other functionalities for express. While refactoring the codebase, I am considering implementing restrictions on the types of responses a ...

Utilizing TS2722 alongside restrictive parameters in tsconfig

I have encountered these errors due to the presence of the strictNullChecks parameter, which is activated by the strict configuration in the tsconfig.json file. It appears that when arguments.length === 2, the ab function should be available (thanks to Fun ...

When attempting to send an email with nodemailer, an error message popped up saying "setImmediate is not defined."

let transporter = nodemailer.createTransport({ host: "sandbox.smtp.mailtrap.io", port: 2525, auth: { user: "xxxxxx", pass: "xxxxxx" }, tls: { rejectUnauthorized: false } ...

Issue: Multiplying values within an array in TypeScript requires that the left-hand side of the arithmetic operation must be of type 'any', 'number', or 'enum'

Having trouble with Typescript as I encounter this error message The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.ts(2362) Specifically facing issues when trying to multi ...

Leveraging Typescript Definitions Files from Definitely Typed with an Outdated Typescript Version

I've been struggling with integrating third party React component libraries into my project that uses Typescript 1.8.10 along with React and Redux. Specifically, I've been attempting to use React Date Picker, but have encountered issues due to th ...

The Angular component fails to refresh after removing an image

After deleting an image, I have been struggling to find a way to update my component instantly without having to refresh the page. Despite trying various methods like using ChangeDetectorRef, I haven't been successful. Any advice on how to achieve thi ...

Issue with decorators not functioning in the latest alpha version of Sequelize v7

As I was exploring sequelize v7 (alpha), I encountered multiple errors when trying out basic examples directly from their documentation. For instance, taken straight from the official documentation import { Sequelize, DataTypes, Model, InferAttributes, Inf ...

Displaying data in a table using NgFor and allowing the user to input the number of columns

My component has the capability to accept an array input, such as [1, 2, 3, 4, 5, 6, 7], and a number of columns input. For example, if a user specifies 3 columns, I want to display the data in a table with 3 columns like this: 1 2 3 4 5 6 7 If the ...

The result of comparing with `instanceof` in TypeScript

class Department { name: string; constructor(n: string) { this.name = n; } describe(this: Department){ console.log('department: ' +this.name); } } const frontend = new Department('frontend'); frontend.describe(); con ...

The latest update of WebStorm in 2016.3 has brought to light an error related to the experimental support for decorators, which may undergo changes in forthcoming

Hello, I recently updated to the latest WebStorm version and encountered this error message: Error:(52, 14) TS1219:Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' ...

Can you explain the distinction between `any[]` and `{ [s: string]: any }`?

I was attempting to make this code snippet function properly: test(a: any[]) { let b: string[][] = []; b.push(Object.keys(a[0])); b.push(...a.map(e => Object.values(e))); } However, the compiler is throwing an error for the b.push(...a.ma ...

Setting up the 'nativescript-stripe' plugin in your NativeScript Vue project for seamless integration

Trying to integrate the «nativescript-stripe» plugin into my Nativescript Vue app has been a challenge. The documentation and demos on the plugin's GitHub are geared towards Angular and TypeScript, making it difficult to adapt for Vue. Can anyone pr ...

How to Generate a Unique URL in Angular 7 Using Typescript

I'm struggling to display or download a .pdf file in my Angular 7 project due to issues with window.URL.createObjectURL. Here's the code snippet I've written: this.userService.getFile(report.id).subscribe( res => { console.log(res) ...

Tips for modifying the text color of a div that is being iterated through using ngFor

I am facing an issue with a div that is being looped using ngFor. What I want to achieve is when a user clicks on one of the divs in the loop, only that particular div should change its text color. If another div is clicked, it should change color while th ...

The crosshair functionality in Zing Chart is causing a CPU leak

After enabling the crosshair feature on my chart, I noticed a significant issue when using Chrome 57 (and even with versions 58 and ZingChart 2.6.0). The CPU usage spikes above 25% when hovering over the chart to activate the crosshair. With two charts, th ...

Error in Reactive Form: Null Property Reading Issue

Issue: Encountered a Cannot read property errors of null error in the form group. I have implemented a reactive form with validation, but I keep running into this specific error. Here is the complete form control setup: <div class="container mt- ...

Prevent modal from closing when clicking outside in React

I am currently working with a modal component in react-bootstrap. Below is the code I used for importing the necessary modules. import React from "react"; import Modal from "react-bootstrap/Modal"; import ModalBody from "react-bootstrap/ModalBody"; impor ...

Tips for Validating Radio Buttons in Angular Reactive Forms and Displaying Error Messages upon Submission

Objective: Ensure that the radio buttons are mandatory. Challenge: The element mat-error and its content are being displayed immediately, even before the form is submitted. It should only show up when the user tries to submit the form. I attempted to use ...

Utilizing Min and Max Validation in Angular 2 Template-Driven Forms

I attempted to incorporate min validation in a template form, but unfortunately it did not function as expected. Could someone provide guidance on how to properly use it in a template form? Thank you in advance for your assistance. <input type= ...

Spread an all-encompassing category across a collection

What is the method in TypeScript to "spread" a generic type across a union? type Box<T> = { content: T }; type Boxes<string | number> = Box<string> | Box<number>; (Given that we are aware of when to use Boxes versus Box) ...