{"action":"created","issue":{"url":"https://api.github.com/repos/npm/npm/issues/15225","repository_url":"https://api.github.com/repos/npm/npm","labels_url":"https://api.github.com/repos/npm/npm/issues/15225/labels{/name}","comments_url":"https://api.github.com/repos/npm/npm/issues/15225/comments","events_url":"https://api.github.com/repos/npm/npm/issues/15225/events","html_url":"https://github.com/npm/npm/issues/15225","id":195689520,"number":15225,"title":"Upgrading npm from version >=3 via `npm install -g npm@latest` version fails on Docker. ","user":{"login":"lxe","id":1486609,"avatar_url":"https://avatars.githubusercontent.com/u/1486609?v=3","gravatar_id":"","url":"https://api.github.com/users/lxe","html_url":"https://github.com/lxe","followers_url":"https://api.github.com/users/lxe/followers","following_url":"https://api.github.com/users/lxe/following{/other_user}","gists_url":"https://api.github.com/users/lxe/gists{/gist_id}","starred_url":"https://api.github.com/users/lxe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lxe/subscriptions","organizations_url":"https://api.github.com/users/lxe/orgs","repos_url":"https://api.github.com/users/lxe/repos","events_url":"https://api.github.com/users/lxe/events{/privacy}","received_events_url":"https://api.github.com/users/lxe/received_events","type":"User","site_admin":false},"labels":[{"id":41616,"url":"https://api.github.com/repos/npm/npm/labels/bug","name":"bug","color":"A328B3","default":true},{"id":493449856,"url":"https://api.github.com/repos/npm/npm/labels/docker","name":"docker","color":"FFE9C5","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-12-15T01:04:45Z","updated_at":"2016-12-18T19:14:19Z","closed_at":null,"body":"#### I'm opening this issue because:\r\n\r\n  - [X] npm is crashing.\r\n  - [X] npm is producing an incorrect install.\r\n  - [X] npm is doing something I don't understand.\r\n  - [ ] Other (_see below for feature requests_):\r\n\r\n#### What's going wrong?\r\n\r\nRunning `npm install@latest -g' using npm 3.10.9 shipped with node v6.9.2 breaks npm installation on docker.\r\n\r\n#### How can the CLI team reproduce the problem?\r\n\r\n1. Make the following Dockerfile:\r\n\r\n```\r\nFROM ubuntu\r\n\r\nRUN apt-get update && apt-get -y install curl\r\nRUN cd /usr && curl -s https://nodejs.org/dist/v6.9.2/node-v6.9.2-linux-x64.tar.gz | tar -zx --strip-components=1\r\n\r\n# Succeeds\r\nRUN npm -v\r\n\r\n# Succeeds\r\nRUN npm install npm@3 -g\r\n\r\n# Fails\r\nRUN npm -v\r\n\r\nCMD npm -v\r\n```\r\n\r\n2. Build it:\r\n\r\n```\r\ndocker build .\r\n```\r\n\r\n3. Observer that layer `RUN npm -v` after installing npm and overriding the previous installation now fails with:\r\n\r\n\r\n```\r\nStep 6/7 : RUN npm -v\r\n ---> Running in 40a70815247d\r\nmodule.js:471\r\n    throw err;\r\n    ^\r\n\r\nError: Cannot find module 'npmlog'\r\n    at Function.Module._resolveFilename (module.js:469:15)\r\n    at Function.Module._load (module.js:417:25)\r\n    at Module.require (module.js:497:17)\r\n    at require (internal/module.js:20:19)\r\n    at /usr/lib/node_modules/npm/bin/npm-cli.js:19:13\r\n    at Object.<anonymous> (/usr/lib/node_modules/npm/bin/npm-cli.js:75:3)\r\n    at Module._compile (module.js:570:32)\r\n    at Object.Module._extensions..js (module.js:579:10)\r\n    at Module.load (module.js:487:32)\r\n    at tryModuleLoad (module.js:446:12)\r\n```\r\n\r\nNOTE: I tested the npm 1.4.28 (node 0.10.42) -> 3 upgrade, and that succeeds! This means that this is some sort of a regression.\r\n\r\nI suspect Docker permission/ownership nuances and other things I don't understand.\r\n\r\n### supporting information:\r\n\r\n - `npm -v` prints: 3.10.9\r\n - `node -v` prints: 6.9.2\r\n - `npm config get registry` prints:\r\n - Windows, OS X/macOS, or Linux?: Darwin *** 16.1.0 Darwin Kernel Version 16.1.0: Thu Oct 13 21:26:57 PDT 2016; root:xnu-3789.21.3~60/RELEASE_X86_64 x86_64\r\n - Network issues:\r\n   - Geographic location where npm was run:\r\n   - [ ] I use a proxy to connect to the npm registry.\r\n   - [ ] I use a proxy to connect to the web.\r\n   - [ ] I use a proxy when downloading Git repos.\r\n   - [ ] I access the npm registry via a VPN\r\n   - [ ] I don't use a proxy, but have limited or unreliable internet access.\r\n - Container:\r\n   - [ ] I develop using Vagrant on Windows.\r\n   - [ ] I develop using Vagrant on OS X or Linux.\r\n   - [X] I develop / deploy using Docker.\r\n   - [ ] I deploy to a PaaS (Triton, Heroku).\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/npm/npm/issues/comments/267839920","html_url":"https://github.com/npm/npm/issues/15225#issuecomment-267839920","issue_url":"https://api.github.com/repos/npm/npm/issues/15225","id":267839920,"user":{"login":"DrStrangepork","id":7307373,"avatar_url":"https://avatars.githubusercontent.com/u/7307373?v=3","gravatar_id":"","url":"https://api.github.com/users/DrStrangepork","html_url":"https://github.com/DrStrangepork","followers_url":"https://api.github.com/users/DrStrangepork/followers","following_url":"https://api.github.com/users/DrStrangepork/following{/other_user}","gists_url":"https://api.github.com/users/DrStrangepork/gists{/gist_id}","starred_url":"https://api.github.com/users/DrStrangepork/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DrStrangepork/subscriptions","organizations_url":"https://api.github.com/users/DrStrangepork/orgs","repos_url":"https://api.github.com/users/DrStrangepork/repos","events_url":"https://api.github.com/users/DrStrangepork/events{/privacy}","received_events_url":"https://api.github.com/users/DrStrangepork/received_events","type":"User","site_admin":false},"created_at":"2016-12-18T19:14:19Z","updated_at":"2016-12-18T19:14:19Z","body":"Workaround: manual install (`curl -sL https://www.npmjs.org/install.sh | sh`) works as expected and results in a `/usr/lib/node_modules/npm/node_modules` folder that contains 85 modules."}}
{"actor":{"display_login":"DrStrangepork"}}