Giter VIP home page Giter VIP logo

Comments (23)

lcardosozago avatar lcardosozago commented on July 20, 2024 1

Sure, thanks. I'll keep trying, if I find any solution I post here.

from image-to-base64.

lcardosozago avatar lcardosozago commented on July 20, 2024 1

@renanbastos93 I couldn't solve it

from image-to-base64.

renanbastos93 avatar renanbastos93 commented on July 20, 2024

Wow, =/

What's version your NodeJS?
Do you this use in Node or browser?

from image-to-base64.

lcardosozago avatar lcardosozago commented on July 20, 2024
$ node --version
v8.11.3

I use Node

from image-to-base64.

lcardosozago avatar lcardosozago commented on July 20, 2024

I'll update node and try again.

from image-to-base64.

renanbastos93 avatar renanbastos93 commented on July 20, 2024

It's okay.

Well, Can you send the log full to I understand what is this error?

from image-to-base64.

lcardosozago avatar lcardosozago commented on July 20, 2024

I did update node and still with the same problem.

ERROR in ./~/image-to-base64/image-to-base64.min.js
Module not found: Error: Can't resolve 'fs' in 'D:\Projetos\...\pwa\node_modules\image-to-base64'
resolve 'fs' in 'D:\Projetos\...\pwa\node_modules\image-to-base64'
  Parsed request is a module
  using description file: D:\Projetos\...\pwa\node_modules\image-to-base64\package.json (relative path: .)
    Field 'browser' doesn't contain a valid alias configuration
  after using description file: D:\Projetos\...\pwa\node_modules\image-to-base64\package.json (relative path: .)
    resolve as module
      D:\Projetos\...\pwa\node_modules\image-to-base64\node_modules doesn't exist or is not a directory
      D:\Projetos\...\pwa\node_modules\node_modules doesn't exist or is not a directory
      D:\Projetos\...\node_modules doesn't exist or is not a directory
      D:\Projetos\node_modules doesn't exist or is not a directory
      D:\node_modules doesn't exist or is not a directory
      looking for modules in D:\Projetos\...\pwa\node_modules
        using description file: D:\Projetos\...\pwa\package.json (relative path: ./node_modules)
          Field 'browser' doesn't contain a valid alias configuration
        after using description file: D:\Projetos\...\pwa\package.json (relative path: ./node_modules)
          using description file: D:\Projetos\...\pwa\package.json (relative path: ./node_modules/fs)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              D:\Projetos\...\pwa\node_modules\fs doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              D:\Projetos\...\pwa\node_modules\fs.js doesn't exist
            .vue
              Field 'browser' doesn't contain a valid alias configuration
              D:\Projetos\...\pwa\node_modules\fs.vue doesn't exist
            .json
              Field 'browser' doesn't contain a valid alias configuration
              D:\Projetos\...\pwa\node_modules\fs.json doesn't exist
            as directory
              D:\Projetos\...\pwa\node_modules\fs doesn't exist
[D:\Projetos\...\pwa\node_modules\image-to-base64\node_modules]
[D:\Projetos\...\pwa\node_modules\node_modules]
[D:\Projetos\...\node_modules]
[D:\Projetos\node_modules]
[D:\node_modules]
[D:\Projetos\...\pwa\node_modules\fs]
[D:\Projetos\...\pwa\node_modules\fs.js]
[D:\Projetos\...\pwa\node_modules\fs.vue]
[D:\Projetos\...\pwa\node_modules\fs.json]
[D:\Projetos\...\pwa\node_modules\fs]
 @ ./~/image-to-base64/image-to-base64.min.js 1:274-287
 @ ./~/babel-loader/lib!./~/vue-loader/lib/selector.js?type=script&index=0!./src/pages/Plants.vue
 @ ./src/pages/Plants.vue
 @ ./src/pages lazy ^\.\/.*\.vue$
 @ ./src/main.js
 @ multi ./build/dev-client babel-polyfill ./src/main.js

from image-to-base64.

renanbastos93 avatar renanbastos93 commented on July 20, 2024

Do you use vue.js right?

So, I need a help to create tests to this case.

This library run good with vanillaJS and NodeJS, now with some frameworks, I need help to make tests and resolve problems.

I think now, we can testing import the library in tag HTML, and using lib normally. Can be?

<script src="node_modules/image-to-base64/image-to-base64.min.js"></script>

from image-to-base64.

lcardosozago avatar lcardosozago commented on July 20, 2024

Yes, I use Vue. How do I use the lib when I import in HTML?
I added this line, but how do I test?

from image-to-base64.

lcardosozago avatar lcardosozago commented on July 20, 2024

If I add:
import image2base64 from 'image-to-base64'
or
const image2base64 = require('image-to-base64')
to my JS files
with this import in HTML, the same error still appearing.

from image-to-base64.

renanbastos93 avatar renanbastos93 commented on July 20, 2024

On component that you'll using, should use this example code:

imageToBase64("https://whatever-image/")
    .then(
        (response) => {
            console.log(response); //iVBORw0KGgoAAAANSwCAIA...
        }
    )
    .catch(
        (error) => {
            console.log(error); //Exepection error....
        }
    )

you can pass url or path relative.

Don't impot on Node, Try using as vanillaJS.

Understood?

from image-to-base64.

lcardosozago avatar lcardosozago commented on July 20, 2024

yep

Uncaught ReferenceError: imageToBase64 is not defined
    at (index):64

and

Uncaught ReferenceError: image2base64 is not defined
    at (index):64

didn't work

from image-to-base64.

renanbastos93 avatar renanbastos93 commented on July 20, 2024

I will to try using Vue.JS and find errors to understand how run to create a fix. However I don't can today.

from image-to-base64.

renanbastos93 avatar renanbastos93 commented on July 20, 2024

Nice, if you wish can open a PR with your solution.

from image-to-base64.

renanbastos93 avatar renanbastos93 commented on July 20, 2024

@lcardosozago you did it?

from image-to-base64.

dilipchandima avatar dilipchandima commented on July 20, 2024

Hi I also have the same question on React Native. I want to convert image from URL to base64 and following error comes,

Failed to load bundle(http://localhost:8081/index.ios.bundle?platform=ios&dev=true) with error:(Unable to resolve module fs from /Users/dileepa/projects/xxx/mobile/node_modules/image-to-base64/image-to-base64.min.js: Module fs does not exist in the Haste module map

This might be related to facebook/react-native#4968
To resolve try the following:

  1. Clear watchman watches: watchman watch-del-all.
  2. Delete the node_modules folder: rm -rf node_modules && npm install.
  3. Reset Metro Bundler cache: rm -rf /tmp/metro-bundler-cache-* or npm start -- --reset-cache.
  4. Remove haste cache: rm -rf /tmp/haste-map-react-native-packager-*. (null))

__38-[RCTCxxBridge loadSource:onProgress:]_block_invoke.248
RCTCxxBridge.mm:429
___ZL36attemptAsynchronousLoadOfBundleAtURLP5NSURLU13block_pointerFvP18RCTLoadingProgressEU13block_pointerFvP7NSErrorP9RCTSourceE_block_invoke.118
__80-[RCTMultipartDataTask URLSession:streamTask:didBecomeInputStream:outputStream:]_block_invoke
-[RCTMultipartStreamReader emitChunk:headers:callback:done:]
-[RCTMultipartStreamReader readAllPartsWithCompletionCallback:progressCallback:]
-[RCTMultipartDataTask URLSession:streamTask:didBecomeInputStream:outputStream:]
__88-[NSURLSession delegate_streamTask:didBecomeInputStream:outputStream:completionHandler:]_block_invoke
NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK
-[NSBlockOperation main]
-[__NSOperationInternal _start:]
_dispatch_client_callout
_dispatch_block_invoke_direct
_dispatch_client_callout
_dispatch_block_invoke_direct
dispatch_block_perform
__NSOQSchedule_f
_dispatch_client_callout
_dispatch_continuation_pop
_dispatch_async_redirect_invoke
_dispatch_root_queue_drain
_dispatch_worker_thread3
_pthread_wqthread
start_wqthread

from image-to-base64.

gubagu avatar gubagu commented on July 20, 2024

Same problem trying to use the library in Angular 8. Any development on this bug?

from image-to-base64.

aqrojo avatar aqrojo commented on July 20, 2024

Hey @renanbastos93
I'm having the same issue with the fs lib when I tried to publish a npm package from a react library, and I solved it by removing the nodejs code from the library so ... maybe the solution will be to split the code in 2 separate versions, one for browser and the other one for node

from image-to-base64.

renanbastos93 avatar renanbastos93 commented on July 20, 2024

@aqrojo

Wow, interesting. So, can you open a pull request making this change?
Today, I am without time to commit to this project I am accepting help.

from image-to-base64.

renanbastos93 avatar renanbastos93 commented on July 20, 2024

@gubagu @dilipchandima @lcardosozago
Hello, was fixed it. Special thanks to @aqrojo to implemented the fix.
Already was published on NPM

from image-to-base64.

aviralgoyal avatar aviralgoyal commented on July 20, 2024

Hi
I'm afraid still facing this issue, I'm using angular 9.

ERROR in ./node_modules/image-to-base64/image-to-base64.min.js
Can't resolve 'fs' in 'filepath/imagetobase64'

ERROR in ./node_modules/image-to-base64/image-to-base64.min.js
Can't resolve 'path' in 'filepath/imagetobase64'

from image-to-base64.

aqrojo avatar aqrojo commented on July 20, 2024

@aviralgoyal try to use this with the latest version:

import imageToBase64 from 'image-to-base64/browser';

from image-to-base64.

aviralgoyal avatar aviralgoyal commented on July 20, 2024

Hi @aqrojo

Worked Perfectly! Thank you so much for the prompt reply. I had found a workaround, so I just got around testing it right now.

Is it mentioned somewhere in the documentation? It would be super easy next time someone faces the same issue!

Thanks a ton
Aviral

from image-to-base64.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.