Skip to content

NodeJS require #133

Description

@dawidfreelancer

HI. Is it possible to import library by
const library = require('library') ?

Activity

  1. Solant commented on May 5, 2020

    @Solant
    Contributor

    Sure, just like in any other nodejs or webpack app

  2. dawidfreelancer commented on May 5, 2020

    @dawidfreelancer
    Author

    But i got this error when i try
    https://pasteboard.co/J70Fp6y.png

  3. Solant commented on May 5, 2020

    @Solant
    Contributor

    you should run 2 npm scripts at the same time:
    npm run start starts actual qode instance, while npm run dev starts webpack bundle for your js code

    so you need to run both start and dev

    UPD: both scripts should be running, if you need to restart app, you can just restart only npm run start task

  4. dawidfreelancer commented on May 5, 2020

    @dawidfreelancer
    Author

    Yes i have started both. Dev server is working but shown error :
    https://pasteboard.co/J70SV3F.png
    and when i try npm run start it cant start
    https://pasteboard.co/J70TCJr.png

    It only happens when i ve my import lines in code

    const memoryjs = require('memoryjs')
    const processes = memoryjs.get.processes()
    console.log(processes)
    

    When i remove these lines app render without problems.
    It's not memoryjs issue because i dont have problem to require it in normal js file and run it with node filename.js

  5. Solant commented on May 5, 2020

    @Solant
    Contributor

    oh, I see now
    memoryjs has some native code that is prebuilt for specific nodejs version
    some additional steps may be required in this case, https://docs.nodegui.org/docs/guides/using-native-node-modules

    or you can try different lib without prebuilt native binaries

  6. dawidfreelancer commented on May 5, 2020

    @dawidfreelancer
    Author

    Ok cant setup it. Anyway thanks help.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions