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

Cannot find module if the path contains illegal character #46

Open
csutorasa opened this issue Jan 1, 2021 · 1 comment
Open

Cannot find module if the path contains illegal character #46

csutorasa opened this issue Jan 1, 2021 · 1 comment

Comments

@csutorasa
Copy link

csutorasa commented Jan 1, 2021

Expected Behaviour

Loaders work if the path contains # character.

Actual Behaviour

Webpack build fails with ERROR (tested on ts-loader and css-loader):

../../a#/ts-loader-path-issue/src/index.ts 39 bytes [not cacheable] [built] [code generated] [1 error]

ERROR in ../../a#/ts-loader-path-issue/src/index.ts
Module build failed (from ../../a#/ts-loader-path-issue/node_modules/ts-loader/index.js):
Error: Cannot find module 'C:\a#\ts-loader-path-issue\node_modules\ts-loader\index.js'
Require stack:
- C:\a#\ts-loader-path-issue\node_modules\loader-runner\lib\loadLoader.js
- C:\a#\ts-loader-path-issue\node_modules\loader-runner\lib\LoaderRunner.js
- C:\a#\ts-loader-path-issue\node_modules\webpack\lib\NormalModule.js
- C:\a#\ts-loader-path-issue\node_modules\webpack\lib\NormalModuleFactory.js
- C:\a#\ts-loader-path-issue\node_modules\webpack\lib\Compiler.js
- C:\a#\ts-loader-path-issue\node_modules\webpack\lib\webpack.js
- C:\a#\ts-loader-path-issue\node_modules\webpack\lib\index.js
- C:\a#\ts-loader-path-issue\node_modules\webpack-cli\lib\webpack-cli.js
- C:\a#\ts-loader-path-issue\node_modules\webpack-cli\lib\bootstrap.js
- C:\a#\ts-loader-path-issue\node_modules\webpack-cli\bin\cli.js
- C:\a#\ts-loader-path-issue\node_modules\webpack\bin\webpack.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (C:\a#\ts-loader-path-issue\node_modules\v8-compile-cache\v8-compile-cache.js:159:20)
    at loadLoader (C:\a#\ts-loader-path-issue\node_modules\loader-runner\lib\loadLoader.js:19:17)
    at iteratePitchingLoaders (C:\a#\ts-loader-path-issue\node_modules\loader-runner\lib\LoaderRunner.js:182:2)
    at runLoaders (C:\a#\ts-loader-path-issue\node_modules\loader-runner\lib\LoaderRunner.js:395:2)
    at NormalModule.doBuild (C:\a#\ts-loader-path-issue\node_modules\webpack\lib\NormalModule.js:631:3)
    at NormalModule.build (C:\a#\ts-loader-path-issue\node_modules\webpack\lib\NormalModule.js:775:15)
    at C:\a#\ts-loader-path-issue\node_modules\webpack\lib\Compilation.js:1236:12

Steps to Reproduce the Problem

On Windows 10 with run these commands in PowerShell (tested with 5.1):

mkdir C:\a#
cd C:\a#
git clone https://github.com/csutorasa/ts-loader-path-issue.git
cd ts-loader-path-issue
npm install
.\node_modules\.bin\webpack
# if webpack fails set execution policy and run the last command again
# Set-ExecutionPolicy Bypass -Scope Process -Force

On Linux run these commands in bash (tested with 5.0.17):

mkdir -p ~/a#
cd ~/a#
git clone https://github.com/csutorasa/ts-loader-path-issue.git
cd ts-loader-path-issue
npm install
node_modules/.bin/webpack

Location of a Minimal Repository that Demonstrates the Issue.

https://github.com/csutorasa/ts-loader-path-issue (ts-loader repo)
https://github.com/csutorasa/loader-path-issue (css-loader repo)

@davidecarlier
Copy link

This took me some time to track down on a coworker machine.
The error happened with style-loader and with html-loader.

This is the log:

ERROR in ../../###projects###/cc-widget-contact/src/css/main.css
Module build failed (from ../../###projects###/cc-widget-contact/node_modules/style-loader/dist/cjs.js):
Error: Cannot find module 'D:\###projects###\cc-widget-contact\node_modules\style-loader\dist\cjs.js'
Require stack:
- D:\###projects###\cc-widget-contact\node_modules\loader-runner\lib\loadLoader.js
- D:\###projects###\cc-widget-contact\node_modules\loader-runner\lib\LoaderRunner.js
- D:\###projects###\cc-widget-contact\node_modules\webpack\lib\NormalModule.js
- D:\###projects###\cc-widget-contact\node_modules\webpack\lib\NormalModuleFactory.js
- D:\###projects###\cc-widget-contact\node_modules\webpack\lib\Compiler.js
- D:\###projects###\cc-widget-contact\node_modules\webpack\lib\webpack.js
- D:\###projects###\cc-widget-contact\node_modules\webpack\lib\index.js
- D:\###projects###\cc-widget-contact\node_modules\webpack-cli\lib\webpack-cli.js
- D:\###projects###\cc-widget-contact\node_modules\webpack-cli\lib\bootstrap.js
- D:\###projects###\cc-widget-contact\node_modules\webpack-cli\bin\cli.js
- D:\###projects###\cc-widget-contact\node_modules\webpack\bin\webpack.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:793:17)
    at Function.Module._load (internal/modules/cjs/loader.js:686:27)
    at Module.require (internal/modules/cjs/loader.js:848:19)
    at require (D:\###projects###\cc-widget-contact\node_modules\v8-compile-cache\v8-compile-cache.js:159:20)
    at loadLoader (D:\###projects###\cc-widget-contact\node_modules\loader-runner\lib\loadLoader.js:19:17)
    at iteratePitchingLoaders (D:\###projects###\cc-widget-contact\node_modules\loader-runner\lib\LoaderRunner.js:182:2)
    at runLoaders (D:\###projects###\cc-widget-contact\node_modules\loader-runner\lib\LoaderRunner.js:397:2)
    at NormalModule.doBuild (D:\###projects###\cc-widget-contact\node_modules\webpack\lib\NormalModule.js:646:3)
    at NormalModule.build (D:\###projects###\cc-widget-contact\node_modules\webpack\lib\NormalModule.js:791:15)
    at D:\###projects###\cc-widget-contact\node_modules\webpack\lib\Compilation.js:1242:12
 @ ../../###projects###/cc-widget-contact/src/index.js 1:0-24

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

No branches or pull requests

2 participants