Skip to content

npm in Node 6.2.0 MSI does not work in Windows Docker container #7044

Closed
@StefanScherer

Description

@StefanScherer
  • Version: 6.2.0
    • Platform: Windows Server 2016 TP5, Microsoft Windows [Version 10.0.14300]
    • Subsystem: Windows Server Core Docker Container

Node.js 6.x has a problem running inside a Windows Docker container. While filling out this template I drilled down that the problem seems to be npm 3.x. You can find the Dockerfiles to build the Windows Docker images with Node at https://github.com/StefanScherer/dockerfiles-windows/tree/master/node

Node 6.2.0:

Running an interactive Windows Docker container with Node.js 6.2.0 shows an error at npm:

C:\> docker run -it stefanscherer/node-windows:6 cmd

Microsoft Windows [Version 10.0.14300]
(c) 2016 Microsoft Corporation. All rights reserved.

C:\>node --version
v6.2.0

C:\>npm --version
fs.js:1568
  return binding.realpath(pathModule._makeLong(path), options.encoding);
                 ^

Error: ENOENT: no such file or directory, realpath 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js'
    at Error (native)
    at Object.realpathSync (fs.js:1568:18)
    at Function.Module._findPath (module.js:167:25)
    at Function.Module._resolveFilename (module.js:438:25)
    at Function.Module._load (module.js:388:25)
    at Function.Module.runMain (module.js:575:10)
    at startup (node.js:160:18)
    at node.js:449:3
fs.js:1568
  return binding.realpath(pathModule._makeLong(path), options.encoding);
                 ^

Error: ENOENT: no such file or directory, realpath 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js'
    at Error (native)
    at Object.realpathSync (fs.js:1568:18)
    at Function.Module._findPath (module.js:167:25)
    at Function.Module._resolveFilename (module.js:438:25)
    at Function.Module._load (module.js:388:25)
    at Function.Module.runMain (module.js:575:10)
    at startup (node.js:160:18)
    at node.js:449:3

But the file is there:

C:\>dir "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js"
 Volume in drive C has no label.
 Volume Serial Number is BA9B-FAE0

 Directory of C:\Program Files\nodejs\node_modules\npm\bin

05/06/2016  10:01 PM             2,073 npm-cli.js
               1 File(s)          2,073 bytes
               0 Dir(s)  21,217,292,288 bytes free

C:\>type "C:\Program Files\nodejs\node_modules\npm\package.json"
{
  "version": "3.8.9",
  "name": "npm",
  "description": "a package manager for JavaScript",

Node 4.4.5:

Running an interactive Windows Docker container with Node.js 4.4.5 works fine.

C:\> docker run -it stefanscherer/node-windows:4 cmd

Microsoft Windows [Version 10.0.14300]
(c) 2016 Microsoft Corporation. All rights reserved.

C:\>node --version
v4.4.5

C:\>npm --version
npm info it worked if it ends with ok
npm info using [email protected]
npm info using [email protected]
npm info ok
2.15.5

Also the onbuild version works on Windows for Node.js apps with a Dockerfile like this:

FROM stefanscherer/node-windows:4-onbuild

and

docker build -t example .

Or even running inside a nanoserver container eg. on Windows 10 Insider 14352 with Docker installed:

FROM stefanscherer/node-windows:4-nano-onbuild

and

docker build --isolation=hyperv -t example .

Metadata

Metadata

Assignees

No one assigned

    Labels

    fsIssues and PRs related to the fs subsystem / file system.installIssues and PRs related to the installers.windowsIssues and PRs related to the Windows platform.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions