title: Module not found: Error: Can't resolve 'react-module-test'
body: <p>I have published a component to our private Sonatype Nexus repository. The project I published is called react-module-test and was successfully downloaded from the repository. However, importing a component of the published project is not possible:</p>
  
  <p><strong>index.js:</strong></p>
  
  <pre><code>import React from 'react';
  import ReactDOM from 'react-dom';
  import App from 'react-module-test';
  import * as serviceWorker from './serviceWorker';
  
  ReactDOM.render(&lt;App /&gt;, document.getElementById('root'));
  module.hot.accept();
  serviceWorker.unregister();
  </code></pre>
  
  <p>The project that is seen in node_modules is not found. When starting the project with <code>npm start</code> I get the following error message:</p>
  
  <pre><code>ERROR in ./src/index.js
  Module not found: Error: Can't resolve 'react-module-test' in '/path/of/the/project/src'
   @ ./src/index.js 4:0-36 7:36-39
   @ multi (webpack)-dev-server/client?http://localhost:8080 (webpack)/hot/dev-server.js ./src/index.js
  </code></pre>
  
  <p><strong>webpack.config.js:</strong></p>
  
  <pre><code>const path = require("path");
  const webpack = require('webpack');
  const HtmlWebpackPlugin = require('html-webpack-plugin');
  
  module.exports = {
    entry: './src/index.js',
    output: {
      path: path.join(__dirname, 'deployment'),
      filename: 'bundle.js'
    },
    plugins: [
      new webpack.HotModuleReplacementPlugin(),
      new HtmlWebpackPlugin({
        template: './src/index.html',
        filename: './index.html'
      })
    ],
    devServer: {
      contentBase: '/dist',
      hot: true
    },
    resolve: {
      extensions: [".jsx", ".json", ".js"],
      symlinks: false
    },
    module: {
      rules: [
        {
          test: /\.jsx?$/,
          exclude: /node_modules/,
          loader: 'babel-loader',
          query: {
            presets: ['@babel/preset-env', '@babel/preset-react']
          }
        },
        {
          test: /\.(css|less)$/,
          use: ["style-loader", "css-loader"]
        },
        {
          test: /\.svg$/,
          loaders: [
            'babel-loader',
            {
              loader: 'react-svg-loader',
              query: {
                jsx: true
              }
            },
          ]
        }
      ]
    }
  };
  </code></pre>
  
  <p><strong>package.json:</strong></p>
  
  <pre><code>{
    "name": "test-app-react",
    "version": "0.1.0",
    "private": true,
    "dependencies": {
      "jquery": "^3.3.1",
      "react": "^16.7.0",
      "react-dom": "^16.7.0",
      "react-module-test": "^2.1.2",
      "react-router": "^4.4.0-beta.1"
    },
    "scripts": {
      "start": "webpack-dev-server --config ./webpack.config.js --display-error-details --open --mode development",
      "build": "webpack --mode build",
      "test": "react-scripts test",
      "eject": "react-scripts eject"
    },
    "eslintConfig": {
      "extends": "react-app"
    },
    "browserslist": [
      "&gt;0.2%",
      "not dead",
      "not ie &lt;= 11",
      "not op_mini all"
    ],
    "devDependencies": {
      "@babel/core": "^7.2.2",
      "@babel/preset-env": "^7.2.3",
      "@babel/preset-react": "^7.0.0",
      "babel-loader": "^8.0.5",
      "css-loader": "^2.1.0",
      "html-webpack-plugin": "^3.2.0",
      "react-hot-loader": "^4.6.3",
      "react-svg-loader": "^2.1.0",
      "style-loader": "^0.23.1",
      "webpack": "^4.28.3",
      "webpack-cli": "^3.2.1",
      "webpack-dev-server": "^3.1.14"
    }
  }
  </code></pre>
  
  <p><strong>index.js of my imported project:</strong></p>
  
  <pre><code>import 'react-app-polyfill/ie9'; 
  import 'react-app-polyfill/ie11';
  import './polyfill'
  import React from 'react';
  import ReactDOM from 'react-dom';
  import './index.css';
  import App from './App';
  import * as serviceWorker from './serviceWorker';
  
  ReactDOM.render(&lt;App /&gt;, document.getElementById('root'));
  
  serviceWorker.unregister();
  </code></pre>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Here the full error log:</p>
  
  <pre><code>ERROR in ./src/index.js
  Module not found: Error: Can't resolve 'react-module-test' in '/Users/User/projects/testapp-react/src'
  resolve 'react-module-test' in '/Users/User/projects/testapp-react/src'
    Parsed request is a module
    using description file: /Users/User/projects/testapp-react/package.json (relative path: ./src)
      Field 'browser' doesn't contain a valid alias configuration
      resolve as module
        /Users/User/projects/testapp-react/src/node_modules doesn't exist or is not a directory
        /Users/User/projects/node_modules doesn't exist or is not a directory
        /Users/node_modules doesn't exist or is not a directory
        /node_modules doesn't exist or is not a directory
        looking for modules in /Users/User/projects/testapp-react/node_modules
          using description file: /Users/User/projects/testapp-react/package.json (relative path: ./node_modules)
            Field 'browser' doesn't contain a valid alias configuration
            using description file: /Users/User/projects/testapp-react/node_modules/react-module-test/package.json (relative path: .)
              no extension
                Field 'browser' doesn't contain a valid alias configuration
                /Users/User/projects/testapp-react/node_modules/react-module-test is not a file
              .jsx
                Field 'browser' doesn't contain a valid alias configuration
        looking for modules in /Users/User/node_modules
          No description file found
          Field 'browser' doesn't contain a valid alias configuration
                /Users/User/projects/testapp-react/node_modules/react-module-test.jsx doesn't exist
              .json
                Field 'browser' doesn't contain a valid alias configuration
                /Users/User/projects/testapp-react/node_modules/react-module-test.json doesn't exist
              .js
                Field 'browser' doesn't contain a valid alias configuration
                /Users/User/projects/testapp-react/node_modules/react-module-test.js doesn't exist
          No description file found
          no extension
            Field 'browser' doesn't contain a valid alias configuration
              as directory
                existing directory
                  using path: /Users/User/projects/testapp-react/node_modules/react-module-test/index
                    using description file: /Users/User/projects/testapp-react/node_modules/react-module-test/package.json (relative path: ./index)
                      no extension
                        Field 'browser' doesn't contain a valid alias configuration
            /Users/User/node_modules/react-module-test doesn't exist
          .jsx
            Field 'browser' doesn't contain a valid alias configuration
                        /Users/User/projects/testapp-react/node_modules/react-module-test/index doesn't exist
                      .jsx
                        Field 'browser' doesn't contain a valid alias configuration
            /Users/User/node_modules/react-module-test.jsx doesn't exist
          .json
            Field 'browser' doesn't contain a valid alias configuration
                        /Users/User/projects/testapp-react/node_modules/react-module-test/index.jsx doesn't exist
                      .json
                        Field 'browser' doesn't contain a valid alias configuration
            /Users/User/node_modules/react-module-test.json doesn't exist
          .js
            Field 'browser' doesn't contain a valid alias configuration
                        /Users/User/projects/testapp-react/node_modules/react-module-test/index.json doesn't exist
                      .js
                        Field 'browser' doesn't contain a valid alias configuration
            /Users/User/node_modules/react-module-test.js doesn't exist
                        /Users/User/projects/testapp-react/node_modules/react-module-test/index.js doesn't exist
          as directory
            /Users/User/node_modules/react-module-test doesn't exist
  [/Users/User/projects/testapp-react/src/node_modules]
  [/Users/User/projects/node_modules]
  [/Users/node_modules]
  [/node_modules]
  [/Users/User/projects/testapp-react/node_modules/react-module-test]
  [/Users/User/node_modules/package.json]
  [/Users/User/projects/testapp-react/node_modules/react-module-test.jsx]
  [/Users/User/projects/testapp-react/node_modules/react-module-test.json]
  [/Users/User/projects/testapp-react/node_modules/react-module-test.js]
  [/Users/User/node_modules/react-module-test/package.json]
  [/Users/User/node_modules/react-module-test]
  [/Users/User/projects/testapp-react/node_modules/react-module-test/index]
  [/Users/User/node_modules/react-module-test.jsx]
  [/Users/User/projects/testapp-react/node_modules/react-module-test/index.jsx]
  [/Users/User/node_modules/react-module-test.json]
  [/Users/User/projects/testapp-react/node_modules/react-module-test/index.json]
  [/Users/User/node_modules/react-module-test.js]
  [/Users/User/projects/testapp-react/node_modules/react-module-test/index.js]
   @ ./src/index.js 4:0-36 8:36-39
  </code></pre>
  
  <p><strong>EDIT2:</strong></p>
  
  <p>If I change this line:</p>
  
  <pre><code>import App from 'react-module-test'; 
  </code></pre>
  
  <p>to:</p>
  
  <pre><code>import App from '../node_modules/react-module-test/src/App.js';
  </code></pre>
  
  <p>I can import the component (even though I get another error). </p>