Tui.image-editor: Can't resolve 'Fabric/fabric.require' in node_modules.

Created on 26 Oct 2018  ·  15Comments  ·  Source: nhn/tui.image-editor


Module not found: Error: Can't resolve 'fabric/dist/fabric.require' in '.\node_modules\tui-image-editor\dist'

I've already looked at former issues with fabric, these are not fixing the problem.

Version

"tui-image-editor": "^3.2.2"
Angular 6.1.0
Node 8.11
Tried with fabric 1.6.7 and 2.4.2

// Write example code
instance = new ImageEditor(document.querySelector('#tui-image-editor'),
        { cssMaxWidth: 700, cssMaxHeight: 500, selectionStyle: { cornerSize: 20, rotatingPointOffset: 70 }
        });
Enhancement

Most helpful comment

There is no fabric.require.js in fabric/dist/, there is only fabric.js but tui-image editor is still looking for fabric.require

Could somebody finally please fix this? The suggested workarounds did not help in my case.

All 15 comments

Apperently i fixed the former issue.

Now it's given me the:

ERROR in ./node_modules/fabric/dist/fabric.require.js
Module not found: Error: Can't resolve 'http' in '.\node_modules\fabric\dist'
ERROR in ./node_modules/fabric/dist/fabric.require.js
Module not found: Error: Can't resolve 'https' in '.\node_modules\fabric\dist'

Anyone know if it's the HttpModule -> HttpClientModule thingy that Angular was going through version 5 to 6?

"Fixed" the problem by replacing
HTTP = require("http"), HTTPS = require("https")
into
HTTP = require("@angular/http"), HTTPS = require("@angular/http") in the fabric.require.js file.

"postinstall": "npm install --no-save --no-optional fabric@~1.6.7"

this seems to be a work-around

“postinstall”:“npm install --no-save --no-optional fabric@~1.6.7”

这似乎是一种解决方法

how to resolve it?

This issue is very annoying. How can I solve this using yarn?

@Fridthjof 's solution worked for me, I also modified the fabric.js file.

@hestellez what did you change in fabric.js?

The solution here and in documentation didn't work for me, unfortunately.

"Fixed" the problem by replacing
HTTP = require("http"), HTTPS = require("https")
into
HTTP = require("@angular/http"), HTTPS = require("@angular/http") in the fabric.require.js file.

Inside node modules, I don't know If there are problems when deploying, but it let me work for the moment

I got the same issue when I tried to install it, and this command solved the issue!
npm install --save --no-optional fabric@^3.3.2

There is no fabric.require.js in fabric/dist/, there is only fabric.js but tui-image editor is still looking for fabric.require

Could somebody finally please fix this? The suggested workarounds did not help in my case.

This is because the postinstall command in package.json in the currently published version installs fabric version ^3.3.2, in which there is no fabric/dist/fabric.require file.

Fortunately, this seems to have been patched in master (there is no postinstall or references to fabric/dist/fabric.require), but there is no release that contains these changes for now.
@jinwoo-kim-nhn @junghwan-park : we really need a release for this, it's very very annoying. Said release would also solve incompatibilities with Yarn as per #286

Here's a workaround: add the following to your package.json scripts section if using yarn:

    "postinstall": "yarn add --peer [email protected] --ignore-optional --ignore-scripts"

Or the following if using npm:

    "postinstall": "npm install --no-optional --igore-scripts [email protected]"

(The --ignore-scripts flag is needed so that postinstall does not call itself in a loop)

This is not really an ideal solution as the wrong version of fabric is still being installed by the tui.image-editor postinstall script, we are just then re-installing the correct version over it.

We'll release the fix for #286, next week

It was released in v3.7.3.

Was this page helpful?
0 / 5 - 0 ratings