Environment
- OS: macOS (Apple Silicon - ARM64)
- Node.js version: v22.22.1 (via nvm)
- Bun version: 1.3.11
- opencode-mem version: 2.13.0
- Package manager: npm
Steps to Reproduce
-
Install opencode-mem globally:
npm install -g opencode-mem
-
Attempt to start the web server using Bun:
cd ~/.nvm/versions/node/v22.22.1/lib/node_modules/opencode-mem
bun -e "
import { startWebServer } from './dist/services/web-server.js';
import { initConfig } from './dist/config.js';
initConfig('$(pwd)');
startWebServer({ port: 4747, host: '127.0.0.1', enabled: true })
.then(s => console.log('Server started on', s.getUrl()))
.catch(e => { console.error('Error:', e); process.exit(1); });
"
Expected Behavior
The web server should start successfully on http://127.0.0.1:4747
Actual Behavior
The application crashes with the following error:
Error:
Something went wrong installing the "sharp" module
Cannot find module '../build/Release/sharp-darwin-arm64v8.node'
Require stack:
- /Users/user/.nvm/versions/node/v22.22.1/lib/node_modules/opencode-mem/node_modules/sharp/lib/sharp.js
- /Users/user/.nvm/versions/node/v22.22.1/lib/node_modules/opencode-mem/node_modules/sharp/lib/constructor.js
- /Users/user/.nvm/versions/node/v22.22.1/lib/node_modules/opencode-mem/node_modules/sharp/lib/index.js
Note: The error occurs in TWO locations:
- Main package:
opencode-mem/node_modules/sharp/
- Dependency:
opencode-mem/node_modules/@xenova/transformers/node_modules/sharp/
Root Cause
The sharp module has native bindings that need to be compiled specifically for macOS ARM64 architecture. The prebuilt binaries included in the default installation don't work correctly on Apple Silicon Macs.
Workaround / Solution
Manually reinstall sharp@0.33.0 in both locations:
# Fix 1: Main package
cd ~/.nvm/versions/node/v22.22.1/lib/node_modules/opencode-mem
npm install sharp@0.33.0 --save
# Fix 2: @xenova/transformers dependency
cd ~/.nvm/versions/node/v22.22.1/lib/node_modules/opencode-mem/node_modules/@xenova/transformers
npm install sharp@0.33.0 --save
After applying both fixes, the server starts successfully.
Additional Context
-
Bun vs Node.js: opencode-mem requires Bun runtime (not Node.js) because it uses bun:sqlite. Attempting to run with Node.js produces: Error: require is not defined in ES module scope, you can use import instead followed by Error: Cannot find package 'bun:sqlite'
-
Tried solutions that didn't work:
npm rebuild sharp - Did not resolve the issue
- Installing with
--platform=darwin --arch=arm64v8 flags - Did not work
- Building from source with
--build-from-source - Did not work
-
What worked: Explicitly installing sharp@0.33.0 in both package locations
Suggested Fix
Consider one of the following:
-
Update sharp dependency: Upgrade to sharp@0.33.0 or later in package.json, which has better macOS ARM64 support
-
Add postinstall script: Add a postinstall script that checks for macOS ARM64 and rebuilds sharp automatically
-
Update installation docs: Document this workaround for macOS ARM64 users until a permanent fix is implemented
-
Use optional dependency: Consider making sharp an optional dependency or finding an alternative that doesn't require native bindings
Related Issues
This may be related to issues with sharp's prebuilt binaries for Apple Silicon. See: https://sharp.pixelplumbing.com/install
Impact: This affects all macOS users with Apple Silicon (M1/M2/M3/M4) chips who install opencode-mem via npm.
Environment
Steps to Reproduce
Install opencode-mem globally:
Attempt to start the web server using Bun:
Expected Behavior
The web server should start successfully on http://127.0.0.1:4747
Actual Behavior
The application crashes with the following error:
Note: The error occurs in TWO locations:
opencode-mem/node_modules/sharp/opencode-mem/node_modules/@xenova/transformers/node_modules/sharp/Root Cause
The sharp module has native bindings that need to be compiled specifically for macOS ARM64 architecture. The prebuilt binaries included in the default installation don't work correctly on Apple Silicon Macs.
Workaround / Solution
Manually reinstall sharp@0.33.0 in both locations:
After applying both fixes, the server starts successfully.
Additional Context
Bun vs Node.js: opencode-mem requires Bun runtime (not Node.js) because it uses
bun:sqlite. Attempting to run with Node.js produces:Error: require is not defined in ES module scope, you can use import insteadfollowed byError: Cannot find package 'bun:sqlite'Tried solutions that didn't work:
npm rebuild sharp- Did not resolve the issue--platform=darwin --arch=arm64v8flags - Did not work--build-from-source- Did not workWhat worked: Explicitly installing sharp@0.33.0 in both package locations
Suggested Fix
Consider one of the following:
Update sharp dependency: Upgrade to sharp@0.33.0 or later in package.json, which has better macOS ARM64 support
Add postinstall script: Add a postinstall script that checks for macOS ARM64 and rebuilds sharp automatically
Update installation docs: Document this workaround for macOS ARM64 users until a permanent fix is implemented
Use optional dependency: Consider making sharp an optional dependency or finding an alternative that doesn't require native bindings
Related Issues
This may be related to issues with sharp's prebuilt binaries for Apple Silicon. See: https://sharp.pixelplumbing.com/install
Impact: This affects all macOS users with Apple Silicon (M1/M2/M3/M4) chips who install opencode-mem via npm.