Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Malformed paths when trying to view /webpack-dev-server route [Windows] #1386

Closed
1 of 2 tasks
kaiyoma opened this issue Apr 24, 2018 · 6 comments
Closed
1 of 2 tasks

Comments

@kaiyoma
Copy link

kaiyoma commented Apr 24, 2018

  • Operating System: Windows 10
  • Node Version: 8.9.0
  • NPM Version: 5.5.1
  • webpack Version: 4.6.0
  • webpack-dev-server Version: 3.1.3
  • This is a bug
  • This is a modification request

Expected Behavior

According to this page:

If you're having trouble, navigating to the /webpack-dev-server route will show where files are served. For example, http://localhost:9000/webpack-dev-server.

However, when I try that with my dev server, I get a JS backtrace in the console:

Error: no such file or directory
    at MemoryFileSystem.readdirSync (C:\...\node_modules\memory-fs\lib\MemoryFileSystem.js:126:10)
    at writeDirectory (C:\...\node_modules\webpack-dev-server\lib\Server.js:124:34)
    at Server.app.get (C:\...\node_modules\webpack-dev-server\lib\Server.js:156:5)
    at Layer.handle [as handle_request] (C:\...\node_modules\express\lib\router\layer.js:95:5)
    at next (C:\...\node_modules\express\lib\router\route.js:137:13)
    at Route.dispatch (C:\...\node_modules\express\lib\router\route.js:112:3)
    at Layer.handle [as handle_request] (C:\...\node_modules\express\lib\router\layer.js:95:5)
    at C:\...\node_modules\express\lib\router\index.js:281:22
    at Function.process_params (C:\...\node_modules\express\lib\router\index.js:335:12)
    at next (C:\...\node_modules\express\lib\router\index.js:275:10)

Actual Behavior

I'm not sure exactly (since I've never used this feature), but I was expecting something helpful to happen.

For Bugs; How can we reproduce the behavior?

Visit http://localhost:9000/webpack-dev-server for a dev server.

@kaiyoma
Copy link
Author

kaiyoma commented Apr 24, 2018

I'm having a lot of trouble upgrading our project to webpack 4 (webpack-dev-server refuses to "just work") and this feature appears to be the only thing that could help. And it's seemingly broken. 😭

@joyfulelement
Copy link

I'm having the exact same issue with a setup of webpack 4 + webpack-dev-server setup with node.js (version v8.9.1). Still digging...

@andreasschuele
Copy link

andreasschuele commented Apr 29, 2018

I had the same issue. It looks like to be an issue with path handling, since after removing white space from my project path it did work again.

There is already an issue for that: webpack/memory-fs#59

@kaiyoma
Copy link
Author

kaiyoma commented Apr 29, 2018

Ah, very interesting. I'm also on Windows and also have spaces in my path, but they can't be removed because they're in the username portion of the path.

@andreasschuele
Copy link

As a quick fix I've added in node_modules\memory-fs\lib\MemoryFileSystem.js the following line to the pathToArray function.

path = path.replace(/\%20/g, " "); // replace encoded white space

The altered function:

function pathToArray(path) {
	path = path.replace(/\%20/g, " "); // replace encoded white space
	path = normalize(path);
	var nix = /^\//.test(path);
	if(!nix) {
		if(!/^[A-Za-z]:/.test(path)) {
			throw new MemoryFileSystemError(errors.code.EINVAL, path);
		}
		path = path.replace(/[\\\/]+/g, "\\"); // multi slashs
		path = path.split(/[\\\/]/);
		path[0] = path[0].toUpperCase();
	} else {
		path = path.replace(/\/+/g, "/"); // multi slashs
		path = path.substr(1).split("/");
	}
	if(!path[path.length-1]) path.pop();
	return path;
}

@michael-ciniawsky michael-ciniawsky added this to the 3.1.6 milestone Aug 23, 2018
@michael-ciniawsky michael-ciniawsky changed the title "Error: no such file or directory" when trying to view /webpack-dev-server route Malformed paths when trying to view /webpack-dev-server route [Windows] Aug 23, 2018
@alexander-akait alexander-akait modified the milestones: 3.1.11, 3.3.0 Feb 21, 2019
@alexander-akait
Copy link
Member

Closing in favor webpack/memory-fs#59, also we have problem in webpack-dev-middleware and already fixed this problem, so update deps, if problem still exists feel fee to open new issue with reproducible test repo, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

No branches or pull requests

5 participants