node-ffi-napi / node-ffi-napi

A foreign function interface (FFI) for Node.js, N-API style
MIT License
995 stars 144 forks source link

Uncaught Error: No native build was found (ElectronJS) #117

Open arturbp opened 3 years ago

arturbp commented 3 years ago

Getting this error:

index.js:59 Uncaught Error: No native build was found for platform=win32 arch=x64 runtime=electron abi=76 uv=1 libc=glibc node=12.13.0 electron=8.3.4 webpack=true loaded from: C:\

at Function../node_modules/node-gyp-build/index.js.load.path (index.js:59)
at load (index.js:21)
at Object.<anonymous> (ref.js:8)
at Object../node_modules/ref-napi/lib/ref.js (ref.js:1476)
at __webpack_require__ (bootstrap:789)
at fn (bootstrap:100)
at Object../node_modules/ffi-napi/lib/ffi.js (ffi.js:7)
at __webpack_require__ (bootstrap:789)
at fn (bootstrap:100)
at Module../BemaSAT/index.ts (bootstrap:856)

Using this Boilerplate for electronjs

Can u help me?

petertorelli commented 3 years ago

I also am using electron-webpack, and I get the same issue as you but only in dist mode ("no native build...").

Does your dev mode work?

petertorelli commented 3 years ago

I just realized my dist vs. dev issue was because ref-napi was installed in devDependencies and not dependencies. This fixed the "no native build..." error.

arturbp commented 3 years ago

I just realized my dist vs. dev issue was because ref-napi was installed in devDependencies and not dependencies. This fixed the "no native build..." error.

I install ffi-napi in prod dependecies. I'm not using ref-napi with this boilerplate.

elberro commented 3 years ago

Hey,

I had the same issue and found this answer: https://github.com/jsdom/jsdom/issues/2066#issuecomment-401556207

I just installed the mentioned package and added this to my main process webpack config:

webpack.main.config.js:

const nodeExternals = require('webpack-node-externals');

module.exports = {
    /**
     * This is the main entry point for your application, it's the first file
     * that runs in the main process.
     */
    entry: './src/index.ts',
    // Put your normal webpack config below here
    module: {
        rules: require('./webpack.rules'),
    },
    resolve: {
        extensions: ['.js', '.ts', '.jsx', '.tsx', '.css', '.json']
    },
    externals: [nodeExternals()],
    // etc configs here
};

This part was new: externals: [nodeExternals()],

and it worked for me, but I have no idea why... by working I mean the issue is gone, but I did not test the lib yet. Cheers

liyuewen commented 3 years ago

嘿,

我遇到了同样的问题并找到了这个答案: jsdom/jsdom#2066(评论)

我刚刚安装了提到的包并将其添加到我的主进程 webpack 配置中:

webpack.main.config.js:

const nodeExternals = require('webpack-node-externals');

module.exports = {
    /**
     * This is the main entry point for your application, it's the first file
     * that runs in the main process.
     */
    entry: './src/index.ts',
    // Put your normal webpack config below here
    module: {
        rules: require('./webpack.rules'),
    },
    resolve: {
        extensions: ['.js', '.ts', '.jsx', '.tsx', '.css', '.json']
    },
    externals: [nodeExternals()],
    // etc configs here
};

这部分是新的: externals: [nodeExternals()],

它对我有用,但我不知道为什么......通过工作我的意思是问题消失了,但我还没有测试 lib。 干杯

Thanks for solving my problem

Aimee1608 commented 2 years ago

nodeExternals()

这个是main 主进程的打包配置吗?