Error: No native build was found for platform
See original GitHub issueWhat version of pkg are you using?
5.7.0
What version of Node.js are you using?
14.19.3
What operating system are you using?
Ubuntu 20.04
What CPU architecture are you using?
x86_64
What Node versions, OSs and CPU architectures are you building for?
node14-linux-x64
Describe the Bug
For some reason when I use the serialport npm package in my app, it compiles but when I try to run it it throws this error (no matter what platform I build for):
$ ./app
pkg/prelude/bootstrap.js:1876
throw error;
^
Error: No native build was found for platform=linux arch=x64 runtime=node abi=83 uv=1 libc=glibc node=14.19.2
loaded from: /snapshot/pkg/node_modules/@serialport/bindings-cpp
at Function.path (/snapshot/pkg/node_modules/node-gyp-build/index.js:60:9)
at load (/snapshot/pkg/node_modules/node-gyp-build/index.js:22:30)
at Object.<anonymous> (/snapshot/pkg/node_modules/@serialport/bindings-cpp/dist/load-bindings.js:10:46)
at Module._compile (pkg/prelude/bootstrap.js:1930:22)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Module.require (internal/modules/cjs/loader.js:974:19)
at Module.require (pkg/prelude/bootstrap.js:1855:31)
at require (internal/modules/cjs/helpers.js:101:18)
Here is my package.json
{
"name": "pkg",
"version": "1.0.0",
"dependencies": {
"serialport": "^10.4.0"
}
}
And here is my app.js
const { SerialPort } = require('serialport')
const port = new SerialPort({
path: '/dev/ttyUSB0',
baudRate: 19200,
})
console.log('Serial port opened successfully!')
And this is how I build:
$ pkg app.js --target=node14-linux-x64
> pkg@5.7.0
Issue Analytics
- State:
- Created a year ago
- Comments:12
Top Results From Across the Web
Error running in VSCode: No native build was found ... - GitHub
0 installed via conda (thus, no nvm ). This was my initial error: Error: No native build was found for platform=linux arch=x64 runtime=node...
Read more >Uncaught Error: No native build was found for platform=win32 ...
I use npm install /path/to/addon to install the addon. Then electron-rebuild and electron-build , which don't complain. But when I run npm start ......
Read more >Hi, can someone help me with this error please, I am unable to ...
Error : No native build was found for platform=win32 arch=x64 runtime=node abi=108 uv=1 libc=glibc node=18.4.0 loaded from…
Read more >Error: No native build was found for platform=win32 arch=x64 ...
Error : No native build was found for platform=win32 arch=x64 runtime=node abi=108 uv=1 libc=glibc node=18.7.0
Read more >Kibana Development 7.15 Yarn Bootstrap Fails no native build ...
[vscode] Error: No native build was found for platform=linux arch=x64 runtime=node abi=83 uv=1 libc=glibc node=14.18.1\n loaded from: ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Indeed! TL;DR Copy the folder
node_modules/@serialport/bindings-cpp/prebuildsto the location of your binary.So, I was having the same issue and couldn’t find the reason. But by looking at the stack trace:
I opened the file referenced here:
which looks like this: (simplified)
There you can see the pattern where it looks for the native prebuilds. Complete source of node-gyp-build
I added
node_modules/@serialport/bindings-cpp/prebuildsto the assets then problem solved.package.json