在本地安装 JSBin

Install JSBin locally

我想在本地跟随 this page 到 运行 JSBin。

我已经在 mac 中安装了 xcode 8.2。现在,npm -v returns 3.10.9node -v returns v7.2.1.

git clone git@github.com:remy/jsbin.gitcd jsbin之后,我修改了package.json使得它里面有"memcached": "2.2.2"(见this thread),然后npm install returns

/Users/softtimur/Startup/WebProjects/tmp/jsbin$ npm install
npm WARN deprecated jade@1.4.2: Jade has been renamed to pug, please install the latest version of pug instead of jade
npm WARN deprecated minimatch@0.2.14: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated graceful-fs@2.0.3: graceful-fs v3.0.0 and before will fail on node releases >= v7.0. Please update to graceful-fs@^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree.
npm WARN deprecated transformers@2.1.0: Deprecated, use jstransformer
npm WARN deprecated node-uuid@1.4.7: use uuid module instead
npm WARN deprecated set-immediate@0.1.1: Use `setimmediate` instead
npm WARN deprecated minimatch@0.3.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated graceful-fs@1.2.3: graceful-fs v3.0.0 and before will fail on node releases >= v7.0. Please update to graceful-fs@^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree.
npm WARN deprecated minimatch@0.0.5: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated jade@0.26.3: Jade has been renamed to pug, please install the latest version of pug instead of jade
npm WARN prefer global js-beautify@1.5.4 should be installed with -g
npm WARN prefer global jshint@0.9.1 should be installed with -g

> sqlite3@2.2.7 install /Users/softtimur/Startup/WebProjects/tmp/jsbin/node_modules/sqlite3
> node-pre-gyp install --fallback-to-build

node-pre-gyp ERR! UNCAUGHT EXCEPTION 
node-pre-gyp ERR! stack Error: Cannot find module 'internal/fs'
node-pre-gyp ERR! stack     at Function.Module._resolveFilename (module.js:470:15)
node-pre-gyp ERR! stack     at Function.Module._load (module.js:418:25)
node-pre-gyp ERR! stack     at Module.require (module.js:498:17)
node-pre-gyp ERR! stack     at require (internal/module.js:20:19)
node-pre-gyp ERR! stack     at evalmachine.<anonymous>:17:20
node-pre-gyp ERR! stack     at Object.<anonymous> (/Users/softtimur/Startup/WebProjects/tmp/jsbin/node_modules/sqlite3/node_modules/node-pre-gyp/node_modules/tar/node_modules/fstream/node_modules/graceful-fs/fs.js:11:8)
node-pre-gyp ERR! stack     at Module._compile (module.js:571:32)
node-pre-gyp ERR! stack     at Object.Module._extensions..js (module.js:580:10)
node-pre-gyp ERR! stack     at Module.load (module.js:488:32)
node-pre-gyp ERR! stack     at tryModuleLoad (module.js:447:12)
node-pre-gyp ERR! System Darwin 16.3.0
node-pre-gyp ERR! command "/usr/local/Cellar/node/7.2.1/bin/node" "/Users/softtimur/Startup/WebProjects/tmp/jsbin/node_modules/sqlite3/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /Users/softtimur/Startup/WebProjects/tmp/jsbin/node_modules/sqlite3
node-pre-gyp ERR! node -v v7.2.1
node-pre-gyp ERR! node-pre-gyp -v v0.5.22
node-pre-gyp ERR! This is a bug in `node-pre-gyp`.
node-pre-gyp ERR! Try to update node-pre-gyp and file an issue if it does not help:
node-pre-gyp ERR!     <https://github.com/mapbox/node-pre-gyp/issues>
jsbin@3.40.2 /Users/softtimur/Startup/WebProjects/tmp/jsbin
├── async@0.1.22 
├── asyncjs@0.0.7 
├─┬ aws-sdk@2.7.17 
│ ├─┬ buffer@4.9.1 
│ │ ├── base64-js@1.2.0 
│ │ ├── ieee754@1.1.8 
│ │ └── isarray@1.0.0 
│ ├── crypto-browserify@1.0.9 
│ ├── jmespath@0.15.0 
│ ├── querystring@0.2.0 
│ ├── sax@1.1.5 
│ ├─┬ url@0.10.3 
│ │ └── punycode@1.3.2 
│ ├── uuid@3.0.0 
│ ├── xml2js@0.4.15 
│ └─┬ xmlbuilder@2.6.2 
│   └── lodash@3.5.0 
├─┬ axon@2.0.3 
│ ├── amp@0.3.1 
│ ├── amp-message@0.1.2 
│ ├── configurable@0.0.1 
│ └── escape-regexp@0.0.1 
├── bcrypt-nodejs@0.0.3 
├── bin-to-file@0.0.5 
├── UNMET PEER DEPENDENCY casperjs@>= 1.1.0-beta3 
......
......
......
npm WARN mocha-casperjs@0.5.8 requires a peer of casperjs@>= 1.1.0-beta3 but none was installed.
npm WARN In sqlite3@2.2.7 replacing bundled version of readable-stream with readable-stream@1.0.34
npm ERR! Darwin 16.3.0
npm ERR! argv "/usr/local/Cellar/node/7.2.1/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v7.2.1
npm ERR! npm  v3.10.9
npm ERR! code ELIFECYCLE

npm ERR! sqlite3@2.2.7 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 7
npm ERR! 
npm ERR! Failed at the sqlite3@2.2.7 install script 'node-pre-gyp install --fallback-to-build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the sqlite3 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-pre-gyp install --fallback-to-build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs sqlite3
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls sqlite3
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/softtimur/Startup/WebProjects/tmp/jsbin/npm-debug.log

有人知道这里出了什么问题吗?

编辑 1: 如果我将 "memcached": "2.2.2""sqlite3": "3.1.8" 放在 package.jsonnpm install returns 中:

/Users/softtimur/Startup/WebProjects/tmp/jsbin$ npm install
npm WARN deprecated jade@1.4.2: Jade has been renamed to pug, please install the latest version of pug instead of jade
npm WARN deprecated graceful-fs@2.0.3: graceful-fs v3.0.0 and before will fail on node releases >= v7.0. Please update to graceful-fs@^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree.
npm WARN deprecated minimatch@0.2.14: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated transformers@2.1.0: Deprecated, use jstransformer
npm WARN deprecated node-uuid@1.4.7: use uuid module instead
npm WARN deprecated minimatch@0.3.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated set-immediate@0.1.1: Use `setimmediate` instead
npm WARN deprecated graceful-fs@1.2.3: graceful-fs v3.0.0 and before will fail on node releases >= v7.0. Please update to graceful-fs@^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree.
npm WARN deprecated minimatch@0.0.5: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated jade@0.26.3: Jade has been renamed to pug, please install the latest version of pug instead of jade
npm WARN prefer global js-beautify@1.5.4 should be installed with -g
npm WARN prefer global jshint@0.9.1 should be installed with -g

> sqlite3@3.1.8 install /Users/softtimur/Startup/WebProjects/tmp/jsbin/node_modules/sqlite3
> node-pre-gyp install --fallback-to-build

[sqlite3] Success: "/Users/softtimur/Startup/WebProjects/tmp/jsbin/node_modules/sqlite3/lib/binding/node-v51-darwin-x64/node_sqlite3.node" is installed via remote

> zmq@2.6.0 install /Users/softtimur/Startup/WebProjects/tmp/jsbin/node_modules/zmq
> node-gyp rebuild

Package libzmq was not found in the pkg-config search path.
Perhaps you should add the directory containing `libzmq.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libzmq' found
gyp: Call to 'pkg-config libzmq --libs' returned exit status 1 while in binding.gyp. while trying to load binding.gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:305:16)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Darwin 16.3.0
gyp ERR! command "/usr/local/Cellar/node/7.2.1/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/softtimur/Startup/WebProjects/tmp/jsbin/node_modules/zmq
gyp ERR! node -v v7.2.1
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok 

> jsbin@3.40.2 postinstall /Users/softtimur/Startup/WebProjects/tmp/jsbin
> grunt build && npm run selenium:install

Running "concat:dist" (concat) task
File "public/js/prod/jsbin-3.40.2.js" created.

Running "concat:runner" (concat) task
File "public/js/prod/runner-3.40.2.js" created.

Running "uglify:dist" (uglify) task
File "public/js/prod/jsbin-3.40.2.min.js" created.

Running "uglify:runner" (uglify) task
File "public/js/prod/runner-3.40.2.min.js" created.

Running "uglify:embed" (uglify) task
File "public/js/embed.min.js" created.

Running "uglify:addons" (uglify) task
File "public/js/prod/addon-tern-3.40.2.min.js" created.

Done, without errors.

> jsbin@3.40.2 selenium:install /Users/softtimur/Startup/WebProjects/tmp/jsbin
> selenium-standalone install

----------
selenium-standalone installation starting
----------

---
selenium install:
from: https://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.1.jar
to: /Users/softtimur/Startup/WebProjects/tmp/jsbin/node_modules/selenium-standalone/.selenium/selenium-server/2.53.1-server.jar
---
chrome install:
from: https://chromedriver.storage.googleapis.com/2.25/chromedriver_mac64.zip
to: /Users/softtimur/Startup/WebProjects/tmp/jsbin/node_modules/selenium-standalone/.selenium/chromedriver/2.25-x64-chromedriver
---
firefox install:
from: https://github.com/mozilla/geckodriver/releases/download/v0.11.1/geckodriver-v0.11.1-macos.tar.gz
to: /Users/softtimur/Startup/WebProjects/tmp/jsbin/node_modules/selenium-standalone/.selenium/geckodriver/0.11.1-x64-geckodriver


selenium-standalone installation [=========           ] 43% 5.7s

-----
selenium-standalone installation finished
-----

> jsbin@3.40.2 prepublish /Users/softtimur/Startup/WebProjects/tmp/jsbin
> npm run snyk-protect


> jsbin@3.40.2 snyk-protect /Users/softtimur/Startup/WebProjects/tmp/jsbin
> snyk protect

Successfully applied Snyk patches
jsbin@3.40.2 /Users/softtimur/Startup/WebProjects/tmp/jsbin
├── async@0.1.22 
├── asyncjs@0.0.7 
├─┬ aws-sdk@2.7.17 
│ ├─┬ buffer@4.9.1 
│ │ ├── base64-js@1.2.0 
│ │ ├── ieee754@1.1.8 
│ │ └── isarray@1.0.0 
│ ├── crypto-browserify@1.0.9 
│ ├── jmespath@0.15.0 
│ ├── querystring@0.2.0 
│ ├── sax@1.1.5 
│ ├─┬ url@0.10.3 
│ │ └── punycode@1.3.2 
│ ├── uuid@3.0.0 
│ ├── xml2js@0.4.15 
│ └─┬ xmlbuilder@2.6.2 
│   └── lodash@3.5.0 
├─┬ axon@2.0.3 
│ ├── amp@0.3.1 
│ ├── amp-message@0.1.2 
│ ├── configurable@0.0.1 
│ └── escape-regexp@0.0.1 
├── bcrypt-nodejs@0.0.3 
├── bin-to-file@0.0.5 
├── UNMET PEER DEPENDENCY casperjs@>= 1.1.0-beta3
......
......
......
npm WARN mocha-casperjs@0.5.8 requires a peer of casperjs@>= 1.1.0-beta3 but none was installed.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: zmq@2.6.0 (node_modules/zmq):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: zmq@2.6.0 install: `node-gyp rebuild`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

npm start returns:

/Users/softtimur/Startup/WebProjects/tmp/jsbin$ npm start

> jsbin@3.40.2 start /Users/softtimur/Startup/WebProjects/tmp/jsbin
> (sleep 2 && open http://localhost:3000) & ./bin/jsbin

Config from /Users/softtimur/Startup/WebProjects/tmp/jsbin/lib/config.local.json
module.js:472
    throw err;
    ^

Error: Cannot find module 'express/node_modules/connect'
    at Function.Module._resolveFilename (module.js:470:15)
    at Function.Module._load (module.js:418:25)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/softtimur/Startup/WebProjects/tmp/jsbin/lib/middleware.js:4:15)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)

npm ERR! Darwin 16.3.0
npm ERR! argv "/usr/local/Cellar/node/7.2.1/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v7.2.1
npm ERR! npm  v3.10.9
npm ERR! code ELIFECYCLE
npm ERR! jsbin@3.40.2 start: `(sleep 2 && open http://localhost:3000) & ./bin/jsbin`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the jsbin@3.40.2 start script '(sleep 2 && open http://localhost:3000) & ./bin/jsbin'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the jsbin package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     (sleep 2 && open http://localhost:3000) & ./bin/jsbin
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs jsbin
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls jsbin
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/softtimur*emphasized text*/Startup/WebProjects/tmp/jsbin/npm-debug.log

编辑 2:

根据 mscdex 的评论,以下操作解决了 libzmq 错误:

  1. 使用 brew 安装 zmq:brew install zmq
  2. export PKG_CONFIG_PATH=/usr/local/Cellar/zeromq/4.2.0/lib/pkgconfig/
  3. sudo visudo 并添加 Defaults env_keep += "PKG_CONFIG_PATH"
  4. package.json
  5. 中将zmq设置为2.15.3

express/node_modules/connect 被硬编码在 lib/middleware.js 中。我把express/node_modules/connect改成了connect,终于可以了。

很可能 sqlite3 需要升级到具有较新 node-pre-gyp 依赖项的最新版本,而后者又应该有自己更新的依赖项才能与现代版本的节点正常工作。

出现 libzmq 错误是因为您没有安装合适的 libzmq 包来构建。

Error: Cannot find module 'express/node_modules/connect' 消息很可能是由于 npm v3 更改了模块的存储方式(以减少深度嵌套)。看来 jsbin 通过硬编码路径而不是使用正确的模块解析来假设 express 的依赖项位于何处。