[英]Building jQuery fails to minify with error “/bin/sh: line 0: test: /usr/bin/node: binary operator expected”, but NodeJS is installed at /usr/bin/node
我正在嘗試從source構建jQuery ,但遇到了一個奇怪的問題。
我可以構建未縮小的版本,但是當它試圖縮小js文件時,出現以下錯誤:
> make ... Building ./dist/jquery.js /bin/sh: line 0: test: /usr/bin/node: binary operator expected You must have NodeJS installed in order to minify jQuery. /bin/sh: line 0: test: /usr/bin/node: binary operator expected You must have NodeJS installed in order to test jQuery against JSHint. /bin/sh: line 0: test: /usr/bin/node: binary operator expected You must have NodeJS installed in order to size jQuery.
有什么奇怪的,不過,是在的NodeJS在安裝/usr/bin/node
。 這里發生了什么?
簽出產生錯誤的行之一:
@@if test ! -z ${JS_ENGINE}; then \
這是${JS_ENGINE}
在Makefile
頂部定義的地方:
JS_ENGINE ?= `which node nodejs 2>/dev/null`
如果我在系統上運行該命令,將得到以下信息:
> which node nodejs 2>/dev/null /usr/bin/node /usr/bin/nodejs
請注意,輸出包含2行,而不是1行!
要解決此問題,請在調用make
時重寫${JS_ENGINE}
屬性,如下所示:
make JS_ENGINE=`which node nodejs 2>/dev/null | head -n 1`
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.