{"action":"created","issue":{"url":"https://api.github.com/repos/minkphp/MinkZombieDriver/issues/168","repository_url":"https://api.github.com/repos/minkphp/MinkZombieDriver","labels_url":"https://api.github.com/repos/minkphp/MinkZombieDriver/issues/168/labels{/name}","comments_url":"https://api.github.com/repos/minkphp/MinkZombieDriver/issues/168/comments","events_url":"https://api.github.com/repos/minkphp/MinkZombieDriver/issues/168/events","html_url":"https://github.com/minkphp/MinkZombieDriver/pull/168","id":147054523,"number":168,"title":"Support and test installation with npm v3","user":{"login":"arithmetric","id":280997,"avatar_url":"https://avatars.githubusercontent.com/u/280997?v=3","gravatar_id":"","url":"https://api.github.com/users/arithmetric","html_url":"https://github.com/arithmetric","followers_url":"https://api.github.com/users/arithmetric/followers","following_url":"https://api.github.com/users/arithmetric/following{/other_user}","gists_url":"https://api.github.com/users/arithmetric/gists{/gist_id}","starred_url":"https://api.github.com/users/arithmetric/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arithmetric/subscriptions","organizations_url":"https://api.github.com/users/arithmetric/orgs","repos_url":"https://api.github.com/users/arithmetric/repos","events_url":"https://api.github.com/users/arithmetric/events{/privacy}","received_events_url":"https://api.github.com/users/arithmetric/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2016-04-08T22:24:04Z","updated_at":"2016-04-10T16:16:39Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/minkphp/MinkZombieDriver/pulls/168","html_url":"https://github.com/minkphp/MinkZombieDriver/pull/168","diff_url":"https://github.com/minkphp/MinkZombieDriver/pull/168.diff","patch_url":"https://github.com/minkphp/MinkZombieDriver/pull/168.patch"},"body":"npm v3, the suggested version of npm for Node.js v5, introduced a \"flat\" module dependency structure. While npm v1 and v2 install the tough-cookie dependency of the zombie module under the zombie module itself (node_modules/zombie/node_modules/tough-cookie), npm v3 likely will not nest the tough-cookie module under zombie but install it at the same level (node_modules/zombie and node_modules/tough-cookie).\r\n\r\nIf zombie is installed with npm v3, then the mink-zombie-server.js script cannot find the tough-cookie module and the script fails with the error:\r\n```\r\nError: Cannot find module 'zombie/node_modules/tough-cookie'\r\n    at Function.Module._resolveFilename (module.js:325:15)\r\n    at Function.Module._load (module.js:276:25)\r\n    at Module.require (module.js:353:17)\r\n    at require (internal/module.js:12:17)\r\n    at Object.<anonymous> (/home/travis/build/arithmetric/MinkZombieDriver/bin/mink-zombie-server.js:4:13)\r\n    at Module._compile (module.js:397:26)\r\n    at Object.Module._extensions..js (module.js:404:10)\r\n    at Module.load (module.js:343:32)\r\n    at Function.Module._load (module.js:300:12)\r\n    at Function.Module.runMain (module.js:429:10)\r\n    at startup (node.js:139:18)\r\n    at node.js:999:3\r\n]\r\n```\r\n\r\nThis error occurs due to the hard-coded path at: https://github.com/minkphp/MinkZombieDriver/blob/master/bin/mink-zombie-server.js#L4\r\n\r\nThis PR provides compatibility for installations with npm v1/v2 or v3 by trying to load tough-cookie from both paths, the npm v3 flat form first, then the legacy nested form.\r\n\r\nAlso, this error was not caught by the Travis tests because they were not configured to use the version of npm included with the version of Node.js used. This PR updates the Travis script to use the npm installed with Node.\r\n\r\nThis test run shows the error when using npm v3 without the code fix: https://travis-ci.org/arithmetric/MinkZombieDriver/jobs/121820946\r\n"},"comment":{"url":"https://api.github.com/repos/minkphp/MinkZombieDriver/issues/comments/208007943","html_url":"https://github.com/minkphp/MinkZombieDriver/pull/168#issuecomment-208007943","issue_url":"https://api.github.com/repos/minkphp/MinkZombieDriver/issues/168","id":208007943,"user":{"login":"aik099","id":1277526,"avatar_url":"https://avatars.githubusercontent.com/u/1277526?v=3","gravatar_id":"","url":"https://api.github.com/users/aik099","html_url":"https://github.com/aik099","followers_url":"https://api.github.com/users/aik099/followers","following_url":"https://api.github.com/users/aik099/following{/other_user}","gists_url":"https://api.github.com/users/aik099/gists{/gist_id}","starred_url":"https://api.github.com/users/aik099/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aik099/subscriptions","organizations_url":"https://api.github.com/users/aik099/orgs","repos_url":"https://api.github.com/users/aik099/repos","events_url":"https://api.github.com/users/aik099/events{/privacy}","received_events_url":"https://api.github.com/users/aik099/received_events","type":"User","site_admin":false},"created_at":"2016-04-10T16:16:38Z","updated_at":"2016-04-10T16:16:38Z","body":"Cool. We already have function for version comparison in JS. We can just place IF around patching code and that's it."}}