title: Webpack is unable to find imports that TypeScript (apparently) finds
body: <p>Background: I started from the (works fine for me) <a href="https://docs.microsoft.com/en-us/aspnet/core/tutorials/signalr-typescript-webpack?view=aspnetcore-2.1&amp;tabs=visual-studio" rel="nofollow noreferrer">ASP.NET Core example of SignalR and webpack</a>.
  My goal is to use <a href="https://github.com/flyover/box2d.ts" rel="nofollow noreferrer">this TypeScript library</a> to do client-side interpolation for a multiplayer game that's server-side authoritative.</p>
  
  <p>The reason I think the issue is webpack-related is that VisualStudio has intellisense for the box2d.ts library, and tsc reports no errors when run on its own.</p>
  
  <p>This is my first project with webpack and TypeScript, so apologies if I've missed something obvious.</p>
  
  <p><strong>The error reported by webpack:</strong></p>
  
  <pre><code>ERROR in ./src/index.ts
  Module not found: Error: Can't resolve 'Box2D' in 
  'C:\Users\nathan.b\Desktop\Gamey\Gamey\src'
   @ ./src/index.ts 2:0-31 3:14-26
  </code></pre>
  
  <p><strong>UPDATE: Error with verbose output:</strong></p>
  
  <pre><code>ERROR in ./src/index.ts
  Module not found: Error: Can't resolve 'Box2D' in 'C:\Users\nathan.b\Desktop\Gamey\Gamey\src'
  resolve 'Box2D' in 'C:\Users\nathan.b\Desktop\Gamey\Gamey\src'
    Parsed request is a module
    using description file: C:\Users\nathan.b\Desktop\Gamey\Gamey\package.json (relative path: ./src)
      Field 'browser' doesn't contain a valid alias configuration
      resolve as module
        C:\Users\nathan.b\Desktop\Gamey\Gamey\src\src doesn't exist or is not a directory
        C:\Users\nathan.b\Desktop\Gamey\Gamey\src\node_modules doesn't exist or is not a directory
        C:\Users\nathan.b\Desktop\Gamey\src doesn't exist or is not a directory
        C:\Users\nathan.b\Desktop\Gamey\node_modules doesn't exist or is not a directory
        C:\Users\nathan.b\Desktop\src doesn't exist or is not a directory
        C:\Users\nathan.b\Desktop\node_modules doesn't exist or is not a directory
        C:\Users\nathan.b\src doesn't exist or is not a directory
        C:\Users\nathan.b\node_modules doesn't exist or is not a directory
        C:\Users\src doesn't exist or is not a directory
        C:\Users\node_modules doesn't exist or is not a directory
        C:\src doesn't exist or is not a directory
        C:\node_modules doesn't exist or is not a directory
        looking for modules in C:\Users\nathan.b\Desktop\Gamey\Gamey\src
          using description file: C:\Users\nathan.b\Desktop\Gamey\Gamey\package.json (relative path: ./src)
            Field 'browser' doesn't contain a valid alias configuration
        looking for modules in C:\Users\nathan.b\Desktop\Gamey\Gamey\node_modules
          using description file: C:\Users\nathan.b\Desktop\Gamey\Gamey\package.json (relative path: ./node_modules)
            Field 'browser' doesn't contain a valid alias configuration
            using description file: C:\Users\nathan.b\Desktop\Gamey\Gamey\package.json (relative path: ./src/Box2D)
              no extension
                Field 'browser' doesn't contain a valid alias configuration
            using description file: C:\Users\nathan.b\Desktop\Gamey\Gamey\package.json (relative path: ./node_modules/Box2D)
              no extension
                Field 'browser' doesn't contain a valid alias configuration
                C:\Users\nathan.b\Desktop\Gamey\Gamey\src\Box2D is not a file
              .js
                Field 'browser' doesn't contain a valid alias configuration
                C:\Users\nathan.b\Desktop\Gamey\Gamey\node_modules\Box2D doesn't exist
              .js
                Field 'browser' doesn't contain a valid alias configuration
                C:\Users\nathan.b\Desktop\Gamey\Gamey\src\Box2D.js doesn't exist
              .ts
                Field 'browser' doesn't contain a valid alias configuration
                C:\Users\nathan.b\Desktop\Gamey\Gamey\node_modules\Box2D.js doesn't exist
              .ts
                Field 'browser' doesn't contain a valid alias configuration
                C:\Users\nathan.b\Desktop\Gamey\Gamey\src\Box2D.ts doesn't exist
                C:\Users\nathan.b\Desktop\Gamey\Gamey\node_modules\Box2D.ts doesn't exist
              as directory
                C:\Users\nathan.b\Desktop\Gamey\Gamey\node_modules\Box2D doesn't exist
              as directory
                existing directory
                  using path: C:\Users\nathan.b\Desktop\Gamey\Gamey\src\Box2D\index
                    using description file: C:\Users\nathan.b\Desktop\Gamey\Gamey\package.json (relative path: ./src/Box2D/index)
                      no extension
                        Field 'browser' doesn't contain a valid alias configuration
                        C:\Users\nathan.b\Desktop\Gamey\Gamey\src\Box2D\index doesn't exist
                      .js
                        Field 'browser' doesn't contain a valid alias configuration
                        C:\Users\nathan.b\Desktop\Gamey\Gamey\src\Box2D\index.js doesn't exist
                      .ts
                        Field 'browser' doesn't contain a valid alias configuration
                        C:\Users\nathan.b\Desktop\Gamey\Gamey\src\Box2D\index.ts doesn't exist
  [C:\Users\nathan.b\Desktop\Gamey\Gamey\src\src]
  [C:\Users\nathan.b\Desktop\Gamey\Gamey\src\node_modules]
  [C:\Users\nathan.b\Desktop\Gamey\src]
  [C:\Users\nathan.b\Desktop\Gamey\node_modules]
  [C:\Users\nathan.b\Desktop\src]
  [C:\Users\nathan.b\Desktop\node_modules]
  [C:\Users\nathan.b\src]
  [C:\Users\nathan.b\node_modules]
  [C:\Users\src]
  [C:\Users\node_modules]
  [C:\src]
  [C:\node_modules]
  [C:\Users\nathan.b\Desktop\Gamey\Gamey\src\Box2D]
  [C:\Users\nathan.b\Desktop\Gamey\Gamey\node_modules\Box2D]
  [C:\Users\nathan.b\Desktop\Gamey\Gamey\src\Box2D.js]
  [C:\Users\nathan.b\Desktop\Gamey\Gamey\node_modules\Box2D.js]
  [C:\Users\nathan.b\Desktop\Gamey\Gamey\src\Box2D.ts]
  [C:\Users\nathan.b\Desktop\Gamey\Gamey\node_modules\Box2D.ts]
  [C:\Users\nathan.b\Desktop\Gamey\Gamey\src\Box2D\index]
  [C:\Users\nathan.b\Desktop\Gamey\Gamey\src\Box2D\index.js]
  [C:\Users\nathan.b\Desktop\Gamey\Gamey\src\Box2D\index.ts]
   @ ./src/index.ts 2:0-31 3:14-26
  </code></pre>
  
  <p><strong>index.ts:</strong><br>
  <em>Just enough to make sure nothing is compiled out.</em></p>
  
  <pre><code>import * as signalR from "@aspnet/signalr";
  import * as box2d from "Box2D";
  
  const g: box2d.b2Vec2 = new box2d.b2Vec2(0, -10)
  console.log(g);
  
  const connection = new signalR.HubConnectionBuilder()
      .withUrl("/hub")
      .build();
  </code></pre>
  
  <p><strong>tsconfig.json:</strong></p>
  
  <pre><code>{
    "compilerOptions": {
      "target": "es6",
      "moduleResolution": "node",
      "baseUrl": ".",
      "paths": {
        "Box2D": [ "./Box2D/Box2D" ]
      }
    }
  }
  </code></pre>
  
  <p><strong>webpack.config.js:</strong></p>
  
  <pre><code>const path = require("path");
  const HtmlWebpackPlugin = require("html-webpack-plugin");
  const CleanWebpackPlugin = require("clean-webpack-plugin");
  const MiniCssExtractPlugin = require("mini-css-extract-plugin");
  
  module.exports = {
      entry: "./src/index.ts",
      output: {
          path: path.resolve(__dirname, "wwwroot"),
          filename: "[name].[chunkhash].js",
          publicPath: "/"
      },
      resolve: {
          extensions: [".js", ".ts"]
      },
      module: {
          rules: [
              {
                  test: /\.ts$/,
                  use: "ts-loader"
              },
              {
                  test: /\.css$/,
                  use: [MiniCssExtractPlugin.loader, "css-loader"]
              }
          ]
      },
      plugins: [
          new CleanWebpackPlugin(["wwwroot/*"]),
          new HtmlWebpackPlugin({
              template: "./src/index.html"
          }),
          new MiniCssExtractPlugin({
              filename: "css/[name].[chunkhash].css"
          })
      ]
  };
  </code></pre>
  
  <p><strong>Project structure:</strong>
  <a href="https://i.stack.imgur.com/EsFzV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EsFzV.png" alt="Project structure"></a></p>