Coder Social home page Coder Social logo

Comments (6)

firsttris avatar firsttris commented on May 29, 2024

Hey nelson,

i now from webpack how this works. but no xp with browserfy.

On Webpack you need to define modules which contains "native node modules" as external dependency.

e.g.
externals: {
"wiringpi-node": "require('wiringpi-node')"
}

Native node modules are written in C or C++ ...
means you can't bundle it, you have to copy the dependency to your build target.

regards
Tristan

from mfrc522-rpi.

nelson2930 avatar nelson2930 commented on May 29, 2024

Thankyou...
As you said, i bundled the file using webpack.
But the output file contains a require statement for wiringpi-node as below.

(function(module, exports) {
module.exports = require("wiringpi-node");
})

My aim is to make MFRC based login system from the client side and for that, I want to read cards from client side browser using the above bundled js file

Since the bundled file contains a require statement for the wiring-pi node, browser shows the following error in console

Uncaught Error: Module name "wiringpi-node" has not been loaded yet for context: _. Use require([])

Is there any option to include wiring-pi node to java-script running on the browser.

Thanks for your help

from mfrc522-rpi.

firsttris avatar firsttris commented on May 29, 2024

In the browser its not possible but in an electron app.

clone https://github.com/electron/electron-quick-start

  • change webpack "target" to electron-renderer
  • in package.json of electron-quick-start point "main" to your bundle.
  • external module (wiring-pi) needs to be installed/copied in electron-quick-start.

from mfrc522-rpi.

PierreTrp avatar PierreTrp commented on May 29, 2024

I have the same issue but i'm not trying to bundle anything, just doing node test/read.js and it throw me this error :

Error: Cannot find module '../build/Release/WiringPi'
    at Function.Module._resolveFilename (module.js:543:15)
    at Function.Module._load (module.js:470:25)
    at Module.require (module.js:593:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/pi/project/node_modules/wiringpi-node/lib/exports.js:1:80)
    at Module._compile (module.js:649:30)
    at Object.Module._extensions..js (module.js:660:10)
    at Module.load (module.js:561:32)
    at tryModuleLoad (module.js:501:12)
    at Function.Module._load (module.js:493:3)

Node v9.10.1
Linux raspberrypi 4.1.18-v7+

EDIT : using node v8.9.4 solved my wiringpi installation problem, i then used wiringpi-node instead of wiring-pi (because of a hardware error) and everything worked fine

from mfrc522-rpi.

firsttris avatar firsttris commented on May 29, 2024

@PierreTrp have you installed deps ? npm install

from mfrc522-rpi.

jhoughjr avatar jhoughjr commented on May 29, 2024

I'm seeing this same thing, not bundling anything and have done nom install wiring-pi.

from mfrc522-rpi.

Related Issues (17)

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.