No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    How to require node addon(c++) in a quasar electron project

    Help
    6
    12
    191
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • G
      gaozhe3321 last edited by

      i have a c++ node addon and build as node file
      when i require this node file
      webpack node-loader popup an error
      said “The specified module could not be found.”
      and the node file name changed to [filehash].node
      like “src-electron\main-process/100b783793116bc6eb2cabbd8bd066d9.node”

      how to deal with it?

      dobbel 1 Reply Last reply Reply Quote 0
      • dobbel
        dobbel @gaozhe3321 last edited by

        @gaozhe3321

        I think you’re better of asking this specialized question in electron forums/communities:

        https://www.electronjs.org/community

        G 1 Reply Last reply Reply Quote 0
        • G
          gaozhe3321 @dobbel last edited by

          @dobbel this error come with webpack’s node-loader error
          if only use electron without wepack it’s gonna work

          1 Reply Last reply Reply Quote 0
          • L
            ly last edited by

            setting node.__dirname to false works for me !

            // quasar.conf

            electron: {
            extendWebpack (cfg) {
            // do something with Electron main process Webpack cfg
            // chainWebpack also available besides this extendWebpack
            console.log("<<<<<<<<<<<<<<<<<<<<<<<<");
            cfg.node.__dirname=false; // set node-loader’s node.__dirname to false, according to node-loader github document
            console.log(cfg.node);
            }
            }

            R 1 Reply Last reply Reply Quote 1
            • R
              rui @ly last edited by

              @ly this is not work for me. any detail.

              C 1 Reply Last reply Reply Quote 1
              • C
                cppgohan last edited by

                not work for me either:

                  "scripts": {
                    "lint": "eslint --ext .js,.vue ./",
                    "test": "echo \"No test specified\" && exit 0",
                    "dev-spa": "quasar dev",
                    "dev-macos": "quasar dev -T darwin -m electron",
                    "build-macos": "quasar build -T darwin -m electron",
                    "inspect-macos": "quasar inspect -T darwin -m electron",
                    "dev-win": "quasar dev -T win32 -m electron",
                    "build-win": "quasar dev -T win32 -m electron"
                  },
                  "dependencies": {
                    "@cloudbase/js-sdk": "^1.4.1",
                    "@quasar/extras": "^1.0.0",
                    "axios": "^0.21.1",
                    "core-js": "^3.6.5",
                    "quasar": "^1.0.0",
                    "trtc-electron-sdk": "^8.4.1"
                  },
                  "devDependencies": {
                    "@quasar/app": "^2.0.0",
                    "@quasar/cli": "^1.1.3",
                    "babel-eslint": "^10.0.1",
                    "devtron": "^1.4.0",
                    "electron": "^9.0.0",
                    "electron-debug": "^3.0.1",
                    "electron-devtools-installer": "^3.0.0",
                    "electron-packager": "^14.1.1",
                    "eslint": "^7.21.0",
                    "eslint-config-prettier": "^8.1.0",
                    "eslint-plugin-vue": "^7.7.0",
                    "eslint-webpack-plugin": "^2.4.0",
                    "native-ext-loader": "^2.3.0"
                  },
                
                1 Reply Last reply Reply Quote 0
                • C
                  cppgohan last edited by

                  is there an example for quasar + electron + native dependency library?

                  1 Reply Last reply Reply Quote 0
                  • C
                    cppgohan @rui last edited by

                    @rui Hi, I did sucess figure this out by modify :

                    3a770671-977b-4e92-8107-b457a61c8399-image.png

                    in the quasar.conf.js

                    G R 2 Replies Last reply Reply Quote 0
                    • G
                      goodwick @cppgohan last edited by

                      @cppgohan

                      Did you do anything else? I’m having the same issue with sharp and adding those lines simply gave me the same error with a different filename;

                      Error: The specified module could not be found.
                      node_modules\sharp\build\Release/sharp.node
                      

                      Even though that file definitely exists at that location.

                      1 Reply Last reply Reply Quote 0
                      • R
                        rui @cppgohan last edited by

                        @cppgohan it worked. thank you very much.

                        1 Reply Last reply Reply Quote 0
                        • G
                          goodwick last edited by

                          Anyone else reading might be helped by the following thread;
                          https://github.com/lovell/sharp/issues/2646

                          In my case, sharp needed to be configured in webpack’s externals, but quasar’s abstraction was a bit hard to navigate since most instructions expect a webpack.config file. The above helped me a lot, even though it may seem simple.

                          1 Reply Last reply Reply Quote 0
                          • G
                            goodwick last edited by

                            Adding it to externals, for me, required putting the following inside chainWebpack under build in quasar.conf.js

                              chain.externals({
                             'sharp': 'commonjs sharp'
                             })
                            
                            1 Reply Last reply Reply Quote 1
                            • First post
                              Last post