2.3.0 breaks path resolution on Windows

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
Webpack fails with error on any path, e.g.:
configuration.context: The provided value “d:\projects\project\src” is not an absolute path!

If the current behavior is a bug, please provide the steps to reproduce.
Windows 10
Git Bash
Node v6.9.1
npm v4.0.0

Create a webpack project and specify a context path, e.g. context: path.resolve(__dirname, 'src')

run webpack with the specified config.

What is the expected behavior?
Webpack uses the path as specified.

If this is a feature request, what is motivation or use case for changing the behavior?

Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.
Windows 10
Git Bash
Node v6.9.1
npm v4.0.0

Author: Fantashit

11 thoughts on “2.3.0 breaks path resolution on Windows

  1. This is caused by a shell launched with a lowercase drive letter. As this will cause problems (i. e. #2815) the validation prevents it.

    How did you launch your shell?

  2. Does it matter how you launch the command prompt as the problem happens with path.resolve paths? Currently cannot use webpack 2.3.0 due to this issue.

  3. Well, default prompt (any prompt) does happily switch between lowercase and uppercase when instructed to… The main problem is that tab-completion fixes casing of directories but not of the drive letters. Because of this I tend to usually be working in a lowercase drive-letter path (in ConEmu) as well.

    image

    It’s an annoyance and for me personally not a big issue, but the moment I upgrade our deps I know every dev is going to come knocking with this (very non-descriptive) error… 🙂

  4. Yep, it seems to be more of an “user error” popping up now as the validation was added. First I couldn’t reproduce it at home but then I noticed that I had switched to drive D by cd D:\path. Everything worked but if I used cd d:\path the lower case would blow the validation. In any case this is a breaking change in my opinion. How many people have windows build scripts doing path changes with lower case letters for drives etc..

  5. Running into this issue with commands launched through Jenkins – works fine on the command prompt, but jobs fail from Jenkins

  6. This is a TOTAL hack, but it works for me as a short term solution so I can continue using my webpack configurations w/2.3.1. I just wanted to share in case it helps anyone else.

    I added a function to my webpack file:

    //to be removed upon webpack fix
    const pathHack = (_path) => {
        return _path.charAt(0).toUpperCase() + _path.slice(1).toLowerCase();
    };
    

    Inside my webpack file, I use that function in my paths so it capitalizes the drive letter:

    module.exports = {
        context: pathHack(path.join(__dirname, "source")),
        entry: {
            "server": pathHack(path.join(__dirname, "source/server"))
        },
        output: {
            path: pathHack(path.join(__dirname, "build")),
            filename: "server.js"
        }
    }
    

    Hope this helps 🙂

  7. What about this (webpack.config.js):

    const path = require('path');
    path: path.resolve(__dirname, './dist'),
    

    __dirname refers to the directory where this webpack.config.js lives

  8. Yeah, the suggested workaround does work:

    const path = require('path');
    path: path.resolve(__dirname, './dist'),
    

    But you shouldn’t have to do that. And FWIW, I’m not launching this from a shell that has a lower-cased first drive letter. I’m using Hyper with Powershell, and my prompt looks like this:

    PS C:\source\Swyfft\Swyfft.Web>
    

Comments are closed.