title: Docker - Can't resolve node module in '/usr/src/app/src'
body: <p>I have this <code>docker</code>service:</p>
  
  <pre><code>client/
        .dockerignore
        Dockerfile-dev
        package.json
        node_modules/
                    react-router-dom/   
                    spotify-web-api-js/
                    and-many-more/
        src/  
           App.jsx
           Spotify.js
  </code></pre>
  
  <p>which installs the following <code>node</code> modules:</p>
  
  <blockquote>
    <p>package.json</p>
  </blockquote>
  
  <pre><code>{
    "name": "client",
    "version": "0.1.0",
    "private": true,
    "dependencies": {
      "axios": "^0.18.0",
      "react": "^16.8.2",
      "react-dom": "^16.8.2",
      "react-router-dom": "^4.3.1",
      "react-scripts": "2.1.5",
      "spotify-web-api-js": "^0.22.1"
    },
    "scripts": {
      "start": "react-scripts start",
      "build": "react-scripts 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": {
      "enzyme": "^3.8.0",
      "enzyme-adapter-react-16": "^1.7.1"
    }
  }
  </code></pre>
  
  <p>like so:</p>
  
  <blockquote>
    <p>Dockerfile-dev</p>
  </blockquote>
  
  <pre><code># base image
  FROM node:11.6.0-alpine
  
  # set working directory
  WORKDIR /usr/src/app
  
  # add `/usr/src/app/node_modules/.bin` to $PATH
  ENV PATH /usr/src/app/node_modules/.bin:$PATH
  
  # install and cache app dependencies
  COPY package.json /usr/src/app/package.json
  RUN npm install --silent
  RUN npm install react-scripts@2.1.2 -g --silent
  
  # start app
  CMD ["npm", "start"]   
  </code></pre>
  
  <p>at the same path, <code>src</code>, however, I'm observing two different behaviours:</p>
  
  <p>1) this works:</p>
  
  <blockquote>
    <p>App.jsx</p>
  </blockquote>
  
  <pre><code>import React, { Component } from 'react';
  import { Route, Switch } from 'react-router-dom';
  </code></pre>
  
  <p>2) but this does not work:</p>
  
  <blockquote>
    <p>Spotify.js</p>
  </blockquote>
  
  <pre><code>import React, { Component } from 'react';   
  import SpotifyWebApi from 'spotify-web-api-js';
  </code></pre>
  
  <p>throwing the following error:</p>
  
  <pre><code>Failed to compile
  ./src/Spotify.js
  Module not found: Can't resolve 'spotify-web-api-js' in '/usr/src/app/src'
  </code></pre>
  
  <blockquote>
    <p>docker-compose-dev.yml</p>
  </blockquote>
  
  <pre><code>  client:
      build:
        context: ./services/client
        dockerfile: Dockerfile-dev
      volumes:
        - './services/client:/usr/src/app'
        - '/usr/src/app/node_modules'
      ports:
        - 3007:3000
      environment:
        - NODE_ENV=development
        - REACT_APP_WEB_SERVICE_URL=${REACT_APP_WEB_SERVICE_URL}
      depends_on:
        - web  
  </code></pre>
  
  <blockquote>
    <p>.dockerignore</p>
  </blockquote>
  
  <pre><code>node_modules
  coverage
  build
  env
  htmlcov
  .dockerignore
  Dockerfile-dev
  Dockerfile-prod
  </code></pre>
  
  <p>what am I missing?</p>