Editor.js: Error when trying to integrate Editorjs with Angular

Created on 4 Jun 2020  路  12Comments  路  Source: codex-team/editor.js

This is the error I get:

ERROR in node_modules/@editorjs/editorjs/types/api/block.d.ts:2:25 - error TS2307: Cannot find module '../../src/types-internal/block-data'.

import {SavedData} from '../../src/types-internal/block-data';

So basically it's trying to import from src folder, but there is no src folder in the @editorjs/editorjs when i use the 'npm install @editorjs/editorjs --save-dev'.
I am aware that there is an ngx-editorjs package, but I'm really frustrated by this issue.
Any help would be highly appreciated.

bug viewed

Most helpful comment

I've investigated the issue and because /src/ folder is not included in the library published to npm, the typing file block-data.d.ts does not exist.

I think it we can fix this by moving the type file from /src/types-internal/block-data.d.ts to /types/api/block-data.d.ts and refactoring all its import declarations.

Proof: Testing by simply adding block-data.d.ts to node_modules in my project works.

I can add a PR with the changes if I have the approval from you guys.

Thanks!

FYI: For me, the previous fix is not a solver, because @2.17.0 doesn't work with the latest plugins, and @2.18.0 give this typing error.

PS:
A cross device temporary fix that I'm using for the time being:

  • Create a folder editorjs-typing-fix containing:
    * block-data.d.ts - copy it from github /src/types-internal/
    *
    block.d.ts with import refactored import {SavedData} from './block-data';
  • Add postinstall script in package.json
    "postinstall": "npm run editorjs-typing-fix",
    "editorjs-typing-fix": "cp -R editorjs-typing-fix/ node_modules/@editorjs/editorjs/types/api/",

All 12 comments

I also have the same bug
help

Me too... My CI log ends with

ERROR in node_modules/@editorjs/editorjs/types/api/block.d.ts:2:25 - error TS2307: Cannot find module '../../src/types-internal/block-data'.
 2 import {SavedData} from '../../src/types-internal/block-data';
                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Running after_script
Uploading artifacts for failed job
ERROR: Job failed: exit code 1

This happened when I updated EditorJS today.

Same here when I updated dependencies.

Install and force a previous version of editorjs (and plugins) with package.json worked for me until they will patch the error:

    "@editorjs/editorjs": "2.17.0",

and then:

npm install

There's a slightly easier way, just ask npm to install an exact version:

npm install @editorjs/[email protected]

Don't forget to install the latest version when the fix for this issue is available (npm install @editorjs/editorjs@latest)

@tommiv, @juanmigonzalez thanks, works for me

I've investigated the issue and because /src/ folder is not included in the library published to npm, the typing file block-data.d.ts does not exist.

I think it we can fix this by moving the type file from /src/types-internal/block-data.d.ts to /types/api/block-data.d.ts and refactoring all its import declarations.

Proof: Testing by simply adding block-data.d.ts to node_modules in my project works.

I can add a PR with the changes if I have the approval from you guys.

Thanks!

FYI: For me, the previous fix is not a solver, because @2.17.0 doesn't work with the latest plugins, and @2.18.0 give this typing error.

PS:
A cross device temporary fix that I'm using for the time being:

  • Create a folder editorjs-typing-fix containing:
    * block-data.d.ts - copy it from github /src/types-internal/
    *
    block.d.ts with import refactored import {SavedData} from './block-data';
  • Add postinstall script in package.json
    "postinstall": "npm run editorjs-typing-fix",
    "editorjs-typing-fix": "cp -R editorjs-typing-fix/ node_modules/@editorjs/editorjs/types/api/",

Thanks for the workaround @tiberiumihai you saved me from stalling progress on an important feature!

Would be keen to see this PR'd and corrected quickly!

Is this fixed with latest version? I have made some changes to this project and built and linked it, it all works fine locally, built I have built the project with the prod script and pushed the changes after the build as I am waiting for my pull request to be reviewed.
My issue is that when I install the remote branch and serve the app, I get the reported error on the
import {SavedData} from '../../src/types-internal/block-data';

Getting the same error.

Seems like no type definitions files (*.d.ts) are generated for the files under src, but other type definitions (e.g. this block.d.ts) depend on them.

@RicoBrase my workaround was to follow on what @tiberiumihai suggested:

I think it we can fix this by moving the type file from /src/types-internal/block-data.d.ts to /types/api/block-data.d.ts and refactoring all its import declarations.

@Teebo Currently working on an easy workaround PR by modifying the .npmignore file. That way, one doesn't have to move around any files.

@RicoBrase Great!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hata6502 picture hata6502  路  3Comments

ghost picture ghost  路  4Comments

vincentdesmares picture vincentdesmares  路  3Comments

ar53n picture ar53n  路  3Comments

ReactorboY picture ReactorboY  路  5Comments