Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when trying to integrate Editorjs with Angular #1183

Closed
aleksadjukic opened this issue Jun 4, 2020 · 13 comments · Fixed by #1251
Closed

Error when trying to integrate Editorjs with Angular #1183

aleksadjukic opened this issue Jun 4, 2020 · 13 comments · Fixed by #1251
Assignees
Labels

Comments

@aleksadjukic
Copy link

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.

@nikolassoares
Copy link

I also have the same bug
help

@gopumon
Copy link

gopumon commented Jun 6, 2020

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.

@juanmigonzalez
Copy link

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

@tommiv
Copy link

tommiv commented Jun 8, 2020

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

npm install @editorjs/editorjs@2.17.0

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

@nikolassoares
Copy link

@tommiv, @juanmigonzalez thanks, works for me

@tiberiumihai
Copy link

tiberiumihai commented Jun 30, 2020

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/",
  • Ensure you have @editorjs/editorjs@2.18.0 in package.json
  • Run npm install

@minirobotdan
Copy link

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!

@Teebo
Copy link

Teebo commented Jul 6, 2020

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';

@RicoBrase
Copy link

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.

@Teebo
Copy link

Teebo commented Jul 8, 2020

@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.

@RicoBrase
Copy link

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

@Teebo
Copy link

Teebo commented Jul 8, 2020

@RicoBrase Great!

@rantunokrek
Copy link

Thanks fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet