Arkadiy Kukarkin
Arkadiy Kukarkin

Reputation: 2293

npm install canvas dies with "clang: error: no such file or directory: '{{}'"

I get this error while installing any node packages that run node-gyp rebuild:

  SOLINK_MODULE(target) Release/canvas-postbuild.node
clang: error: no such file or directory: '{{}'
make: *** [Release/canvas-postbuild.node] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:810:12)
gyp ERR! System Darwin 14.0.0
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/arkadiy/node-canvas
gyp ERR! node -v v0.10.33
gyp ERR! node-gyp -v v1.0.1
gyp ERR! not ok

I have npm 1.4.28 and all of /usr/local is chowned to me. clang is recent-ish:

Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.0.0
Thread model: posix

The error is completely ungoogleable (seriously, try it) and I can't even tell where clang is being invoked because the stack trace is only for the callback handler. It seems like a shell substitution/xargs issue almost?

Upvotes: 0

Views: 1700

Answers (2)

Arkadiy Kukarkin
Arkadiy Kukarkin

Reputation: 2293

Turns out I had a literal LDFLAGS='{} -L/usr/local/opt/openssl/lib' because of something that wasn't being expanded by the shell. Never mind!

Upvotes: 0

Scott Stensland
Scott Stensland

Reputation: 28305

I would say your node/npm install is suspect. If you start from their github

https://github.com/Automattic/node-canvas

and download the repo

git clone https://github.com/Automattic/node-canvas.git

cd node-canvas 
npm install .    

notice the period in above command - that gets upstream dependencies

I just did this and all is well - if you get errors doing above then I suggest you expunge node/npm and install from source. The following steps give you such a clean node/npm install from source

to start fresh remove prior node and npm installs as well as these :

sudo mv ~/.npmrc ~/.npmrc_ignore
sudo mv ~/.npm   ~/.npm_ignore
sudo mv ~/tmp    ~/tmp_ignore
sudo mv ~/.npm-init.js ~/.npm-init.js_ignore

download source from : http://nodejs.org/download/

cd node-v0.10.33

define environment variable NODE_PATH as the dir for subsequent module installs

export NODE_PARENT=/some/desired/install/path_goes_here

export NODE_PARENT=/usr/local/bin/nodejs   # use this ONLY if you MUST install as root (sudo)
export NODE_PARENT=${HOME}/nodejs-v0.10.33 # use this if you want to install modules as yourself

export PATH=${NODE_PARENT}/bin:${PATH}
export NODE_PATH=${NODE_PARENT}/lib/node_modules

./configure   --prefix=${NODE_PARENT}

make
make install

which puts it into dir defined by above --prefix

when you use syntax : npm install -g some_cool_module the -g for global installs it into dir $NODE_PATH and not your $PWD

IMPORTANT put above three export xxx=yyy commands into your ~/.bashrc or some such to persist these environment variable changes

Upvotes: 2

Related Questions