evanw / esbuild

An extremely fast bundler for the web
https://esbuild.github.io/
MIT License
38.26k stars 1.16k forks source link

dyld: Symbol not found: _clock_gettime #1278

Closed yourVictor closed 3 years ago

yourVictor commented 3 years ago

操作系统(os): mac node: v14.16.1 npm: 6.14.12

npm install 的时候报错

> esbuild@0.11.20 postinstall /Users/halvie/Downloads/github/vue3-ele-admin-pure/node_modules/esbuild
> node install.js

dyld: Symbol not found: _clock_gettime
  Referenced from: /Users/halvie/Downloads/github/vue3-ele-admin-pure/node_modules/esbuild/bin/esbuild__
  Expected in: flat namespace

The version of the downloaded binary is incorrect: Command failed: /Users/halvie/Downloads/github/vue3-ele-admin-pure/node_modules/esbuild/bin/esbuild__ --version
dyld: Symbol not found: _clock_gettime
  Referenced from: /Users/halvie/Downloads/github/vue3-ele-admin-pure/node_modules/esbuild/bin/esbuild__
  Expected in: flat namespace
evanw commented 3 years ago

I googled this for you and this was the first result: https://stackoverflow.com/questions/66741383/dyld-symbol-not-found-clock-gettime-after-installing-golang. It sounds like you are using an unsupported version of macOS. You will either have to upgrade your operating system or install the WebAssembly version to use esbuild: https://esbuild.github.io/getting-started/#wasm.

evanw commented 3 years ago

Closing since esbuild is not supported on this platform. Workarounds are described above.

fergardi commented 3 years ago

That happened to me as well. I'm on macOS v10.11.6. Unfortunately my current hardware cannot support a more modern version.

> esbuild@0.12.24 postinstall /Library/WebServer/Documents/WorkspacePHP/mage/node_modules/@angular-devkit/build-angular/node_modules/esbuild
> node install.js

dyld: Symbol not found: _clock_gettime
  Referenced from: /Library/WebServer/Documents/WorkspacePHP/mage/node_modules/@angular-devkit/build-angular/node_modules/esbuild/bin/esbuild__
  Expected in: flat namespace

The version of the downloaded binary is incorrect: Command failed: /Library/WebServer/Documents/WorkspacePHP/mage/node_modules/@angular-devkit/build-angular/node_modules/esbuild/bin/esbuild__ --version
dyld: Symbol not found: _clock_gettime
  Referenced from: /Library/WebServer/Documents/WorkspacePHP/mage/node_modules/@angular-devkit/build-angular/node_modules/esbuild/bin/esbuild__
  Expected in: flat namespace

I've tried the alternative WASM version. But no luck so far.

npm install esbuild-wasm

Are there more steps I should follow in order to make this work?

Thanks in advance.

evanw commented 3 years ago

The platforms that esbuild currently supports are the same platforms that Go currently supports since esbuild is written in Go. The latest version of Go (1.17) only supports macOS 10.13 or higher (released in 2017).

The WASM version should work since WASM is platform-independent and presumably node's WASM support for macOS 10.11 works. That's the approach I'd recommend. What does "no luck so far" mean? Do you get an error?

If you really want to use the native version of esbuild, you could try building from source using Go version 1.14 (the last version to support macOS 10.11).

fergardi commented 3 years ago

I'm trying to develop and compile an Angular12 project, but keep getting the same error, even after installing the esbuild-wasm package.

I don't have the esbuild dependency directly in my package.json so I guess it is a chained dependency I cannot get rid of.

So I don't really know how to bypass this installation error.

Thanks for your response.

fergardi commented 2 years ago

For anybody having the same issue, see https://github.com/sveltejs/kit/issues/3028#issuecomment-991941064 for an alternative solution.

DespertaWeb commented 2 years ago

As @fergardi links to, I just managed to survive the planned obsolescence thanks to: https://github.com/sveltejs/kit/issues/3028#issuecomment-991941064

Issue: Old OS => MacOS Sierra : v10.12.6

SOLUTION:

  1. Update your package.json, like os:

    "devDependencies":{
    "esbuild-wasm":"latest"
    },
    "pnpm":{
    "overrides":{
    "esbuild":"npm:esbuild-wasm@latest"
    }
    }
  2. Use to PNPM:

    1. Install pnpm: https://pnpm.io/installation
    2. install packages: pnpm i
    3. Run your server, for example: pnpm dev
  3. Back to the game!

guizhixiao commented 2 years ago

As @fergardi links to, I just managed to survive the planned obsolescence thanks to: sveltejs/kit#3028 (comment)

Issue: Old OS => MacOS Sierra : v10.12.6

SOLUTION:

  1. Update your package.json, like os:
"devDependencies":{
  "esbuild-wasm":"latest"
},
"pnpm":{
  "overrides":{
    "esbuild":"npm:esbuild-wasm@latest"
  }
}
  1. Use to PNPM:

    1. Install pnpm: https://pnpm.io/installation
    2. install packages: pnpm i
    3. Run your server, for example: pnpm dev
  2. Back to the game!

thanks, This method solved my problem

hacker112 commented 1 year ago

I had the same issue still running on Mac OS X El Capitan 10.11.6 when I wanted to test Vite that uses esbuild. Here is my hacky solution to redirect esbuild to esbuild-wasm without PNPM :)

fix-esbuild.sh:

#!/bin/sh

npm i
npm i -D esbuild-wasm
rm -rf node_modules/esbuild
ln -s $(pwd)/node_modules/esbuild-wasm ./node_modules/esbuild

package.json:

{
  "name": "vite-project",
  "private": true,
  "version": "0.0.0",
  "type": "module",
  "scripts": {
    "dev": "vite",
    "build": "tsc && vite build",
    "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
    "preview": "vite preview"
  },
  "dependencies": {
    "react": "^18.2.0",
    "react-dom": "^18.2.0"
  },
  "devDependencies": {
    "@types/react": "^18.2.15",
    "@types/react-dom": "^18.2.7",
    "@typescript-eslint/eslint-plugin": "^6.0.0",
    "@typescript-eslint/parser": "^6.0.0",
    "@vitejs/plugin-react": "^4.0.3",
    "esbuild-wasm": "^0.19.2",
    "eslint": "^8.45.0",
    "eslint-plugin-react-hooks": "^4.6.0",
    "eslint-plugin-react-refresh": "^0.4.3",
    "typescript": "^5.0.2",
    "vite": "^4.4.5"
  }
}