Search code examples
javascriptnode.jsnpmapple-m1apple-silicon

npm Node.js Error: No native build was found M2 MacBook


I got this error on my M2 MacBook, running a project, that worked on my old Intel MacBook. Do you have any idea what the problem is?

I am using bun but npm run dev (node 18) gives me the same error.

The exact same error occurred on other projects.

Package.json dependencies:

"devDependencies": {
  "@types/three": "^0.143.1",
  "parcel": "^2.7.0"
},
"dependencies": {
  "three": "^0.143.0"
}

Console output for bun run dev:

$ parcel src/index.html --open
Error: No native build was found for platform=darwin arch=x64 runtime=node abi=108 uv=1 libc=glibc node=18.7.0
    loaded from: /Users/frankmayer/Documents/Git/WorldArchitect/WebGLPreview/node_modules/lmdb and package: @lmdb/lmdb-darwin-x64

    at load.path (/Users/frankmayer/Documents/Git/WorldArchitect/WebGLPreview/node_modules/node-gyp-build-optional-packages/index.js:64:9)
    at Object.load [as default] (/Users/frankmayer/Documents/Git/WorldArchitect/WebGLPreview/node_modules/node-gyp-build-optional-packages/index.js:20:30)
    at Object.<anonymous> (/Users/frankmayer/Documents/Git/WorldArchitect/WebGLPreview/node_modules/lmdb/dist/index.cjs:47:47)
    at Module._compile (/Users/frankmayer/Documents/Git/WorldArchitect/WebGLPreview/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
    at Module._extensions..js (node:internal/modules/cjs/loader:1174:10)
    at Module.load (node:internal/modules/cjs/loader:998:32)
    at Module._load (node:internal/modules/cjs/loader:839:12)
    at Module.require (node:internal/modules/cjs/loader:1022:19)
    at require (/Users/frankmayer/Documents/Git/WorldArchitect/WebGLPreview/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
    at _lmdb (/Users/frankmayer/Documents/Git/WorldArchitect/WebGLPreview/node_modules/@parcel/cache/lib/LMDBCache.js:61:39)
Script error "dev" exited with 1 status

Thanks in advance!


Solution

  • You can override a version using the override option in you package.json.

    Read more about this option here: https://docs.npmjs.com/cli/v8/configuring-npm/package-json#overrides

    For me, the solution was to add this to my package.json:

    "overrides": {
      "lmdb": "2.6.0-alpha6",
      "@lmdb/lmdb-darwin-arm64": "2.6.0-alpha6",
      "@lmdb/lmdb-darwin-x64": "2.6.0-alpha6",
    }
    

    This feature is currently (Aug. 2022) not supported by bun!

    Yarn does this using resolutions: https://classic.yarnpkg.com/lang/en/docs/selective-version-resolutions