webpack-contrib / node-loader

node loader for native modules
MIT License
119 stars 43 forks source link

Can't load .node module #11

Closed Arti3DPlayer closed 4 years ago

Arti3DPlayer commented 7 years ago

I'm using https://github.com/resin-io-modules/drivelist that use drivelist.node module.

require('bindings')('drivelist');

My config:

const config = {
    entry: [
        './app/index.js'
    ],
    output: {
        path: path.resolve(__dirname, 'app'),
        filename: 'bundle.js'
    },
    devtool: "source-map",
    target: 'node-webkit',
    node: {
        os: true,
        fs: true,
        child_process: true,
        __dirname: true,
        __filename: true
    },
    plugins: [],
    module: {
        rules: [
            {
                test: /\.node$/,
                use: 'node-loader'
            }
        ]
    }
};
alexander-akait commented 7 years ago

@Arti3DPlayer Which is error your get?

Arti3DPlayer commented 7 years ago

@evilebottnawi On this line it says that binding can't find module: https://github.com/resin-io-modules/drivelist/blob/master/lib/drivelist.js#L53

(this line calls c++ module)

Error: Could not locate the bindings file. Tried:
→ Z:\Jscode\rf_configurator\build\RaceFlight\win64\build\drivelist.node
 → Z:\Jscode\rf_configurator\build\RaceFlight\win64\build\Debug\drivelist.node
 → Z:\Jscode\rf_configurator\build\RaceFlight\win64\build\Release\drivelist.node
 → Z:\Jscode\rf_configurator\build\RaceFlight\win64\out\Debug\drivelist.node
 → Z:\Jscode\rf_configurator\build\RaceFlight\win64\Debug\drivelist.node
 → Z:\Jscode\rf_configurator\build\RaceFlight\win64\out\Release\drivelist.node
 → Z:\Jscode\rf_configurator\build\RaceFlight\win64\Release\drivelist.node
 → Z:\Jscode\rf_configurator\build\RaceFlight\win64\build\default\drivelist.node
 → Z:\Jscode\rf_configurator\build\RaceFlight\win64\compiled\8.1.4\win32\x64\drivelist.node

Even when I put drivelist.node into /Users/myname/Jscode/myproject/out/Release/drivelist.node it don't see it :(

alexander-akait commented 7 years ago

@Arti3DPlayer seems problem in paths Z:\Jscode\rf_configurator\build\RaceFlight\win64\Debug\drivelist.node !== /Users/myname/Jscode/myproject/out/Release/drivelist.node. Maybe something wrong with configuration.

cap-Bernardito commented 4 years ago

node-loader responsible for loading native node modules with .node extension. To do this, you need to specify the path to the imported module

The correct code would look like this:

import drivelist from 'drivelist/build/Release/drivelist.node';

If the problem is actual, please open a new issue with a minimum reproducible repository.