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

webpack generates error when run in a directory starting with an exclamation sign #6742

Closed
doberkofler opened this issue Mar 13, 2018 · 9 comments · Fixed by #6754
Closed

Comments

@doberkofler
Copy link

doberkofler commented Mar 13, 2018

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

What is the current behavior?
Using webpack in a directory start starts with !, generates errors but works as expected when the directory does not start with !


D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test>npm run build

> example@1.0.0 build D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test
> webpack --progress --display-error-details

Hash: 03eec963e3df63b69ec7
Version: webpack 3.11.0
Time: 3824ms
   Asset     Size  Chunks             Chunk Names
index.js  7.37 kB       0  [emitted]  index
   [0] ./src/index.js 21 bytes {0} [built]
   [1] ./src/index.css 4.48 kB {0} [built] [failed] [1 error]

ERROR in ./src/index.css
Module build failed: EntryModuleNotFoundError: Entry module not found: Error: Can't resolve 'test\src\index.css' in 'D:\MyDev\ljs_app\trunk\periscope\examples\w
ebpack\!test\src'
    at moduleFactory.create (D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\node_modules\webpack\lib\Compilation.js:411:30)
    at factory (D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\node_modules\webpack\lib\NormalModuleFactory.js:237:20)
    at resolver (D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\node_modules\webpack\lib\NormalModuleFactory.js:60:20)
    at asyncLib.parallel (D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\node_modules\webpack\lib\NormalModuleFactory.js:127:20)
    at D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\node_modules\async\dist\async.js:3874:9
    at D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\node_modules\async\dist\async.js:473:16
    at iteratorCallback (D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\node_modules\async\dist\async.js:1048:13)
    at D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\node_modules\async\dist\async.js:958:16
    at D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\node_modules\async\dist\async.js:3871:13
    at resolvers.normal.resolve (D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\node_modules\webpack\lib\NormalModuleFactory.js:119:22)
    at onError (D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\node_modules\enhanced-resolve\lib\Resolver.js:65:10)
    at loggingCallbackWrapper (D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
    at runAfter (D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\node_modules\enhanced-resolve\lib\Resolver.js:158:4)
    at innerCallback (D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\node_modules\enhanced-resolve\lib\Resolver.js:146:3)
    at loggingCallbackWrapper (D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
    at next (D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\node_modules\tapable\lib\Tapable.js:252:11)
    at D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\node_modules\enhanced-resolve\lib\UnsafeCachePlugin.js:40:4
    at loggingCallbackWrapper (D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
    at runAfter (D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\node_modules\enhanced-resolve\lib\Resolver.js:158:4)
    at innerCallback (D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\node_modules\enhanced-resolve\lib\Resolver.js:146:3)
    at loggingCallbackWrapper (D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
    at next (D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\node_modules\tapable\lib\Tapable.js:252:11)
    at innerCallback (D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\node_modules\enhanced-resolve\lib\Resolver.js:144:11)
    at loggingCallbackWrapper (D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
    at next (D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\node_modules\tapable\lib\Tapable.js:249:35)
    at resolver.doResolve.createInnerCallback (D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\node_modules\enhanced-resolve\lib\DescriptionFilePlugin.j
s:44:6)
    at loggingCallbackWrapper (D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
    at afterInnerCallback (D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\node_modules\enhanced-resolve\lib\Resolver.js:166:11)
    at loggingCallbackWrapper (D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
    at next (D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\node_modules\tapable\lib\Tapable.js:249:35)
 @ ./src/index.css
 @ ./src/index.js

ERROR in ./src/index.css
Module not found: Error: Can't resolve 'test/node_modules/css-loader/lib/css-base.js' in 'D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\src'
resolve 'test/node_modules/css-loader/lib/css-base.js' in 'D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\src'
  Parsed request is a module
  using description file: D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\package.json (relative path: ./src)
    Field 'browser' doesn't contain a valid alias configuration
  after using description file: D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\package.json (relative path: ./src)
    resolve as module
      D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\src\node_modules doesn't exist or is not a directory
      D:\MyDev\ljs_app\trunk\periscope\examples\webpack\node_modules doesn't exist or is not a directory
      D:\MyDev\ljs_app\trunk\periscope\examples\node_modules doesn't exist or is not a directory
      D:\MyDev\ljs_app\trunk\periscope\node_modules doesn't exist or is not a directory
      D:\MyDev\ljs_app\trunk\node_modules doesn't exist or is not a directory
      D:\MyDev\ljs_app\node_modules doesn't exist or is not a directory
      D:\MyDev\node_modules doesn't exist or is not a directory
      D:\node_modules doesn't exist or is not a directory
      looking for modules in D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\node_modules
        using description file: D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\package.json (relative path: ./node_modules)
          Field 'browser' doesn't contain a valid alias configuration
        after using description file: D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\package.json (relative path: ./node_modules)
          using description file: D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\package.json (relative path: ./node_modules/test/node_modules/css-load
er/lib/css-base.js)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\node_modules\test\node_modules\css-loader\lib\css-base.js doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\node_modules\test\node_modules\css-loader\lib\css-base.js.js doesn't exist
            .json
              Field 'browser' doesn't contain a valid alias configuration
              D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\node_modules\test\node_modules\css-loader\lib\css-base.js.json doesn't exist
            as directory
              D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\node_modules\test\node_modules\css-loader\lib\css-base.js doesn't exist
[D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\src\node_modules]
[D:\MyDev\ljs_app\trunk\periscope\examples\webpack\node_modules]
[D:\MyDev\ljs_app\trunk\periscope\examples\node_modules]
[D:\MyDev\ljs_app\trunk\periscope\node_modules]
[D:\MyDev\ljs_app\trunk\node_modules]
[D:\MyDev\ljs_app\node_modules]
[D:\MyDev\node_modules]
[D:\node_modules]
[D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\node_modules\test\node_modules\css-loader\lib\css-base.js]
[D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\node_modules\test\node_modules\css-loader\lib\css-base.js.js]
[D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\node_modules\test\node_modules\css-loader\lib\css-base.js.json]
[D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\node_modules\test\node_modules\css-loader\lib\css-base.js]
 @ ./src/index.css 1:27-88
 @ ./src/index.js
Child extract-text-webpack-plugin ..!test\node_modules\extract-text-webpack-plugin\dist ..!test\node_modules\css-loader\index.js??ref--1-1!..!test\src\index.css
:

    ERROR in Entry module not found: Error: Can't resolve 'test\src\index.css' in 'D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\src'
    resolve 'test\src\index.css' in 'D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\src'
      Parsed request is a module
      using description file: D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\package.json (relative path: ./src)
        Field 'browser' doesn't contain a valid alias configuration
      after using description file: D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\package.json (relative path: ./src)
        resolve as module
          D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\src\node_modules doesn't exist or is not a directory
          D:\MyDev\ljs_app\trunk\periscope\examples\webpack\node_modules doesn't exist or is not a directory
          D:\MyDev\ljs_app\trunk\periscope\examples\node_modules doesn't exist or is not a directory
          D:\MyDev\ljs_app\trunk\periscope\node_modules doesn't exist or is not a directory
          D:\MyDev\ljs_app\trunk\node_modules doesn't exist or is not a directory
          D:\MyDev\ljs_app\node_modules doesn't exist or is not a directory
          D:\MyDev\node_modules doesn't exist or is not a directory
          D:\node_modules doesn't exist or is not a directory
          looking for modules in D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\node_modules
            using description file: D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\package.json (relative path: ./node_modules)
              Field 'browser' doesn't contain a valid alias configuration
            after using description file: D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\package.json (relative path: ./node_modules)
              using description file: D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\package.json (relative path: ./node_modules/test/src/index.css)
                no extension
                  Field 'browser' doesn't contain a valid alias configuration
                  D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\node_modules\test\src\index.css doesn't exist
                .js
                  Field 'browser' doesn't contain a valid alias configuration
                  D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\node_modules\test\src\index.css.js doesn't exist
                .json
                  Field 'browser' doesn't contain a valid alias configuration
                  D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\node_modules\test\src\index.css.json doesn't exist
                as directory
                  D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test\node_modules\test\src\index.css doesn't exist
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! example@1.0.0 build: `webpack --progress --display-error-details`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the example@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\doberkofler.LBITS\AppData\Roaming\npm-cache\_logs\2018-03-13T16_50_39_385Z-debug.log

D:\MyDev\ljs_app\trunk\periscope\examples\webpack\!test>

If the current behavior is a bug, please provide the steps to reproduce.
just run webpack --progress --display-error-details in a directory that starts with an exclamation sign.

minimal reproduceable repo:
https://github.com/doberkofler/webpack_issue_6742

webpack.config.js:

'use strict';

const path = require('path');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');

module.exports = function config(env) {
	return {
		entry: {
			index: './src/index.js'
		},
		output: {
			path: path.resolve(__dirname, 'dist'),
			filename: '[name].js'
		},
		module: {
			rules: [
				{
					test: /\.js$/i,
					include: /src/,
					exclude: /node_modules/,
					use: {
						loader: 'babel-loader'
					}
				},
				{
					test: /\.css$/i,
					include: /src/,
					exclude: /node_modules/,
					use: ExtractTextPlugin.extract([{
						loader: 'css-loader',
						options: {
							sourceMap: false
						}
					}])
				}
			]
		},
		plugins: [
			new ExtractTextPlugin('[name].css')
		]
	};
};

What is the expected behavior?
webpack should not fail or at least report that it cannot be used in certain directories.

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.
node: v8.10.0
webpack: 3.11.0

@chengluyu
Copy link

chengluyu commented Mar 14, 2018

Simply remove exclamation sign from your directory name because it's a part of loader syntax:

Loaders are activated by using loadername! prefixes in require() statements, or are automatically applied via regex from your webpack configuration – see configuration.

@doberkofler
Copy link
Author

As written in my problem description I do obviously undertsand that the exclamation sign is the problem but:p it took me several hours to find out and I wanted to keep others from falling into the same trap.

  • why is it the problem (I understand the files but not the directory) ?
  • does the error message in any way help me to detect this problem ?
  • couldn’t webpack warn me when just starting a build ?

@chengluyu
Copy link

@doberkofler
Because internally webpack use absolute paths. Before you, other people had encountered the same problem. See #5320.

@doberkofler
Copy link
Author

@chengluyu I see. This actually strongly suggests that webpack should really check for an unsupported project directory name and give a proper error message.

@sokra
Copy link
Member

sokra commented Mar 14, 2018

We could add a schema validation error when somebody passes an path with ! as absolute path in the config.

This could be added to the custom absolutePath schema validator in schemas. Send a PR.

@byzyk
Copy link
Member

byzyk commented Mar 14, 2018

I can have a look at it

@doberkofler
Copy link
Author

@sokra Unfortunately I do not have the needed webpack knowledge to do a PR myself.

@chengluyu
Copy link

@byzyk I'm working on it. I added an extra check before this line.

@doberkofler
Copy link
Author

Thank you all!

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

Successfully merging a pull request may close this issue.

5 participants