webpack-contrib / node-loader

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

【import .node file】Cannot read property 'dlopen' of undefined #10

Closed alyen028 closed 4 years ago

alyen028 commented 7 years ago

1、 webpackConfig module: { loaders: [ { test: /.js$/, loader: 'babel-loader' }, { test: /.node$/, loader: 'node-loader' } ] }, resolve: { //自动扩展文件后缀名,意味着我们require模块可以省略不写后缀名 extensions: ['.js', '.json', '.node'], } 2、main.js import node from 'hello.node'; or var dddd = require('./hello.node'); all display errors: Uncaught Error: Cannot open F:\web\event\node_modules\hello.node: TypeError: Cannot read property 'dlopen' of undefined

what 's wrong with it ? thank you for your reply !

Ericxgao commented 6 years ago

I'm also getting this issue.

Uncaught Error: Cannot open /Users/eric/Documents/ITTH/itth/node_modules/talib/build/Release/talib.node: TypeError: Cannot read property 'dlopen' of undefined
    at Object.<anonymous> (talib.node:1)
    at Object../node_modules/talib/build/Release/talib.node (talib.node:1)
    at __webpack_require__ (bootstrap b34e1b5959f12fd9b616:678)
    at fn (bootstrap b34e1b5959f12fd9b616:88)
    at Object../src/App.js (App.css?9a66:26)
    at __webpack_require__ (bootstrap b34e1b5959f12fd9b616:678)
    at fn (bootstrap b34e1b5959f12fd9b616:88)
    at Object../src/index.js (index.css?f255:26)
    at __webpack_require__ (bootstrap b34e1b5959f12fd9b616:678)
    at fn (bootstrap b34e1b5959f12fd9b616:88)
    at Object.0 (registerServiceWorker.js:108)
    at __webpack_require__ (bootstrap b34e1b5959f12fd9b616:678)
    at bootstrap b34e1b5959f12fd9b616:724
    at bootstrap b34e1b5959f12fd9b616:724
Foristkirito commented 5 years ago

same issue on windows 10

gentios commented 5 years ago

+1 anyone found a solution for this ?

kihayu commented 5 years ago

I have the same issue on Mac OS. Does anyone have a solution or a workaround for the problem?

iaaaan commented 5 years ago

Same issue 🙏

meetmahajan commented 5 years ago

While exploring with Chrome-Extension, I installed RobotJS for desktop automation. At runtime, it is throwing the same error given below,

Uncaught Error: Cannot open C:\Users\Ashutec\Desktop\add-to-crm\node_modules\robotjs\build\Release\robotjs.node: TypeError: Cannot read property 'dlopen' of undefined at Object.<anonymous> (chrome-extension://filhinahhlohnlcejgbfooccoeaofjog/scripts/content.js:1) at Object.<anonymous> (chrome-extension://filhinahhlohnlcejgbfooccoeaofjog/scripts/content.js:1) at n (chrome-extension://filhinahhlohnlcejgbfooccoeaofjog/scripts/content.js:1) at Object.<anonymous> (chrome-extension://filhinahhlohnlcejgbfooccoeaofjog/scripts/content.js:1) at n (chrome-extension://filhinahhlohnlcejgbfooccoeaofjog/scripts/content.js:1) at Object.<anonymous> (chrome-extension://filhinahhlohnlcejgbfooccoeaofjog/scripts/content.js:1) at n (chrome-extension://filhinahhlohnlcejgbfooccoeaofjog/scripts/content.js:1) at Object.<anonymous> (chrome-extension://filhinahhlohnlcejgbfooccoeaofjog/scripts/content.js:1) at n (chrome-extension://filhinahhlohnlcejgbfooccoeaofjog/scripts/content.js:1) at chrome-extension://filhinahhlohnlcejgbfooccoeaofjog/scripts/content.js:1

image

kreezire commented 5 years ago

i am facing the same issue on Mac.

liuyanxing commented 5 years ago

mainWindow = new BrowserWindow({ width: 800, height: 600, webPreferences: {nodeIntegration: true} }) webPreferences: {nodeIntegration: true} solved my problem

kreezire commented 5 years ago

@lyanxing, is this with electron? How do we make these changes to make a distributable build?

cap-Bernardito commented 4 years ago

You are probably running the code in a browser. node-loader only works locally on node and electron envs and is not designed to work in a browser.

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

alexander-akait commented 4 years ago

Other solution is set right target and __dirname:

target: 'node',
node: {
  __dirname: false,
},