title: CRA build fail on netlify but not locally, cannot find module of local method?
body: <p>I have an issue with netlify when attempting to deploy my site. It doesn't seem to be able to find local modules.</p>
  <p>Here is the log:</p>
  <pre><code>12:54:43 AM: Build ready to start
  12:54:45 AM: build-image version: 09c2cdcdf242cf2f57c9ee0fcad9d298fad9ad41
  12:54:45 AM: build-image tag: v3.5.0
  12:54:45 AM: buildbot version: 8df8a50b1177b0b57364d20e0ea150448924cebf
  12:54:45 AM: Fetching cached dependencies
  12:54:45 AM: Starting to download cache of 5.2MB
  12:54:45 AM: Finished downloading cache in 180.688403ms
  12:54:45 AM: Starting to extract cache
  12:54:45 AM: Finished extracting cache in 118.246837ms
  12:54:45 AM: Finished fetching cache in 304.995388ms
  12:54:45 AM: Starting to prepare the repo for build
  12:54:46 AM: Preparing Git Reference refs/heads/main
  12:54:47 AM: Different build dir detected, going to use the one specified in the Netlify configuration file: 'client' versus '/client' in the Netlify UI
  12:54:47 AM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'client/build' versus 'build' in the Netlify UI
  12:54:47 AM: Starting build script
  12:54:47 AM: Installing dependencies
  12:54:47 AM: Python version set to 2.7
  12:54:49 AM: v12.18.0 is already installed.
  12:54:50 AM: Now using node v12.18.0 (npm v6.14.4)
  12:54:50 AM: Started restoring cached build plugins
  12:54:50 AM: Finished restoring cached build plugins
  12:54:50 AM: Attempting ruby version 2.7.1, read from environment
  12:54:52 AM: Using ruby version 2.7.1
  12:54:52 AM: Using PHP version 5.6
  12:54:52 AM: Started restoring cached node modules
  12:54:52 AM: Finished restoring cached node modules
  12:54:52 AM: Started restoring cached yarn cache
  12:54:52 AM: Finished restoring cached yarn cache
  12:54:52 AM: Installing yarn at version 1.22.4
  12:54:52 AM: Installing Yarn!
  12:54:52 AM: &gt; Downloading tarball...
  12:54:52 AM: [1/2]: https://yarnpkg.com/downloads/1.22.4/yarn-v1.22.4.tar.gz --&gt; /tmp/yarn.tar.gz.SCC7CjcRQU
  12:54:52 AM:   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
  12:54:52 AM:                                  Dload  Upload   Total   Spent    Left  Speed
  12:54:52 AM:   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  12:54:53 AM:   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  12:54:53 AM: 100    80  100    80    0     0    257      0 --:--:-- --:--:-- --:--:--   257
  12:54:53 AM: 100    93  100    93    0     0    141      0 --:--:-- --:--:-- --:--:--   141
  12:54:53 AM:   0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
  12:54:53 AM: 100   643  100   643    0     0    608      0  0:00:01  0:00:01 --:--:--  627k
  12:54:54 AM: 100 1215k  100 1215k    0     0   804k      0  0:00:01  0:00:01 --:--:--  804k
  12:54:54 AM: [2/2]: https://yarnpkg.com/downloads/1.22.4/yarn-v1.22.4.tar.gz.asc --&gt; /tmp/yarn.tar.gz.SCC7CjcRQU.asc
  12:54:54 AM: 100    84  100    84    0     0   3026      0 --:--:-- --:--:-- --:--:--  3026
  12:54:54 AM: 100    97  100    97    0     0   1749      0 --:--:-- --:--:-- --:--:--  1749
  12:54:54 AM: 100   647  100   647    0     0   3586      0 --:--:-- --:--:-- --:--:--  3586
  12:54:54 AM: 100  1028  100  1028    0     0   4598      0 --:--:-- --:--:-- --:--:--  4598
  12:54:54 AM: &gt; Verifying integrity...
  12:54:54 AM: gpg: Signature made Mon 09 Mar 2020 03:52:13 PM UTC using RSA key ID 69475BAA
  12:54:54 AM: gpg: Good signature from &quot;Yarn Packaging &lt;yarn@dan.cx&gt;&quot;
  12:54:54 AM: gpg: WARNING: This key is not certified with a trusted signature!
  12:54:54 AM: gpg:          There is no indication that the signature belongs to the owner.
  12:54:54 AM: Primary key fingerprint: 72EC F46A 56B4 AD39 C907  BBB7 1646 B01B 86E5 0310
  12:54:54 AM:      Subkey fingerprint: 6D98 490C 6F1A CDDD 448E  4595 4F77 6793 6947 5BAA
  12:54:54 AM: &gt; GPG signature looks good
  12:54:54 AM: &gt; Extracting to ~/.yarn...
  12:54:54 AM: &gt; Adding to $PATH...
  12:54:55 AM: &gt; Successfully installed Yarn 1.22.4! Please open another terminal where the `yarn` command will now be available.
  12:54:55 AM: Installing NPM modules using Yarn version 1.22.4
  12:54:56 AM: yarn install v1.22.4
  12:54:56 AM: [1/4] Resolving packages...
  12:54:57 AM: [2/4] Fetching packages...
  12:55:28 AM: info fsevents@2.1.3: The platform &quot;linux&quot; is incompatible with this module.
  12:55:28 AM: info &quot;fsevents@2.1.3&quot; is an optional dependency and failed compatibility check. Excluding it from installation.
  12:55:28 AM: info fsevents@1.2.13: The platform &quot;linux&quot; is incompatible with this module.
  12:55:28 AM: info &quot;fsevents@1.2.13&quot; is an optional dependency and failed compatibility check. Excluding it from installation.
  12:55:28 AM: [3/4] Linking dependencies...
  12:55:28 AM: warning &quot; &gt; @testing-library/user-event@12.1.10&quot; has unmet peer dependency &quot;@testing-library/dom@&gt;=7.21.4&quot;.
  12:55:28 AM: warning &quot; &gt; react-masonry-component@6.2.1&quot; has incorrect peer dependency &quot;react@^0.14.0 || ^15.0.0-0 || ^16.0.0-0&quot;.
  12:55:28 AM: warning &quot; &gt; react-pdf@5.0.0&quot; has incorrect peer dependency &quot;react@^16.3.0&quot;.
  12:55:28 AM: warning &quot; &gt; react-pdf@5.0.0&quot; has incorrect peer dependency &quot;react-dom@^16.3.0&quot;.
  12:55:28 AM: warning &quot;react-pdf &gt; worker-loader@3.0.5&quot; has unmet peer dependency &quot;webpack@^4.0.0 || ^5.0.0&quot;.
  12:55:28 AM: warning &quot; &gt; react-slick@0.27.12&quot; has incorrect peer dependency &quot;react@^0.14.0 || ^15.0.1 || ^16.0.0&quot;.
  12:55:28 AM: warning &quot; &gt; react-slick@0.27.12&quot; has incorrect peer dependency &quot;react-dom@^0.14.0 || ^15.0.1 || ^16.0.0&quot;.
  12:55:28 AM: warning &quot; &gt; semantic-ui-react@2.0.1&quot; has incorrect peer dependency &quot;react@^16.8.0&quot;.
  12:55:28 AM: warning &quot; &gt; semantic-ui-react@2.0.1&quot; has incorrect peer dependency &quot;react-dom@^16.8.0&quot;.
  12:55:28 AM: warning &quot;semantic-ui-react &gt; @fluentui/react-component-event-listener@0.51.2&quot; has incorrect peer dependency &quot;react@^16.8.0&quot;.
  12:55:28 AM: warning &quot;semantic-ui-react &gt; @fluentui/react-component-event-listener@0.51.2&quot; has incorrect peer dependency &quot;react-dom@^16.8.0&quot;.
  12:55:28 AM: warning &quot;semantic-ui-react &gt; @fluentui/react-component-ref@0.51.2&quot; has incorrect peer dependency &quot;react@^16.8.0&quot;.
  12:55:28 AM: warning &quot;semantic-ui-react &gt; @fluentui/react-component-ref@0.51.2&quot; has incorrect peer dependency &quot;react-dom@^16.8.0&quot;.
  12:55:28 AM: warning &quot;semantic-ui-react &gt; @semantic-ui-react/event-stack@3.1.1&quot; has incorrect peer dependency &quot;react@^16.0.0&quot;.
  12:55:28 AM: warning &quot;semantic-ui-react &gt; @semantic-ui-react/event-stack@3.1.1&quot; has incorrect peer dependency &quot;react-dom@^16.0.0&quot;.
  12:55:28 AM: warning &quot;semantic-ui-react &gt; react-popper@2.2.3&quot; has incorrect peer dependency &quot;react@^16.8.0&quot;.
  12:55:28 AM: warning &quot; &gt; slick-carousel@1.8.1&quot; has unmet peer dependency &quot;jquery@&gt;=1.8.0&quot;.
  12:55:45 AM: [4/4] Building fresh packages...
  12:55:49 AM: Done in 52.82s.
  12:55:49 AM: NPM modules installed using Yarn
  12:55:49 AM: Started restoring cached go cache
  12:55:49 AM: Finished restoring cached go cache
  12:55:49 AM: go version go1.14.4 linux/amd64
  12:55:49 AM: go version go1.14.4 linux/amd64
  12:55:49 AM: Installing missing commands
  12:55:49 AM: Verify run directory
  12:55:51 AM: ​
  12:55:51 AM: ────────────────────────────────────────────────────────────────
  12:55:51 AM:   Netlify Build                                                 
  12:55:51 AM: ────────────────────────────────────────────────────────────────
  12:55:51 AM: ​
  12:55:51 AM: ❯ Version
  12:55:51 AM:   @netlify/build 5.3.3
  12:55:51 AM: ​
  12:55:51 AM: ❯ Flags
  12:55:51 AM:   deployId: 5fc202431c76591b2b498486
  12:55:51 AM:   mode: buildbot
  12:55:51 AM: ​
  12:55:51 AM: ❯ Current directory
  12:55:51 AM:   /opt/build/repo/client
  12:55:51 AM: ​
  12:55:51 AM: ❯ Config file
  12:55:51 AM:   No config file was defined: using default values.
  12:55:51 AM: ​
  12:55:51 AM: ❯ Context
  12:55:51 AM:   production
  12:55:51 AM: ​
  12:55:51 AM: ────────────────────────────────────────────────────────────────
  12:55:51 AM:   1. Build command from Netlify app                             
  12:55:51 AM: ────────────────────────────────────────────────────────────────
  12:55:51 AM: ​
  12:55:51 AM: $ yarn build
  12:55:52 AM: yarn run v1.22.4
  12:55:52 AM: $ react-scripts build
  12:55:54 AM: Creating an optimized production build...
  12:56:14 AM: Failed to compile.
  12:56:14 AM: 
  12:56:14 AM: ./src/containers/home/HomeTitle.tsx
  12:56:14 AM: Cannot find module: 'utils/userInfoFill'. Make sure this package is installed.
  12:56:14 AM: You can install this package by running: yarn add utils/userInfoFill.
  12:56:14 AM: error Command failed with exit code 1.
  12:56:14 AM: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
  12:56:14 AM: ​
  12:56:14 AM: ────────────────────────────────────────────────────────────────
  12:56:14 AM:   &quot;build.command&quot; failed                                        
  12:56:14 AM: ────────────────────────────────────────────────────────────────
  12:56:14 AM: ​
  12:56:14 AM:   Error message
  12:56:14 AM:   Command failed with exit code 1: yarn build
  12:56:14 AM: ​
  12:56:14 AM:   Error location
  12:56:14 AM:   In Build command from Netlify app:
  12:56:14 AM:   yarn build
  12:56:14 AM: ​
  12:56:14 AM:   Resolved config
  12:56:14 AM:   build:
  12:56:14 AM:     base: /opt/build/repo/client
  12:56:14 AM:     command: yarn build
  12:56:14 AM:     commandOrigin: ui
  12:56:14 AM:     publish: /opt/build/repo/client/build
  12:56:14 AM: Caching artifacts
  12:56:14 AM: Started saving node modules
  12:56:14 AM: Finished saving node modules
  12:56:14 AM: Started saving build plugins
  12:56:14 AM: Finished saving build plugins
  12:56:14 AM: Started saving yarn cache
  12:56:14 AM: Finished saving yarn cache
  12:56:14 AM: Started saving pip cache
  12:56:14 AM: Finished saving pip cache
  12:56:14 AM: Started saving emacs cask dependencies
  12:56:14 AM: Finished saving emacs cask dependencies
  12:56:14 AM: Started saving maven dependencies
  12:56:14 AM: Finished saving maven dependencies
  12:56:14 AM: Started saving boot dependencies
  12:56:14 AM: Finished saving boot dependencies
  12:56:14 AM: Started saving go dependencies
  12:56:14 AM: Finished saving go dependencies
  12:56:17 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
  12:56:17 AM: Failing build: Failed to build site
  12:56:17 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2
  12:56:17 AM: Finished processing build request in 1m32.457785673s
  </code></pre>
  <p><code>utils/userInfoFill</code> is a function I made located under <code>./src/utils/userInfoFill.ts</code> and it looks like :</p>
  <pre><code>import {userinfo} from 'data/userinfo'
  
  export const userInfoFill = (str: string, repl_string?: string) =&gt; {
    if (repl_string) {
      const re = new RegExp(&quot;%userinfo%&quot;, &quot;g&quot;);
      return str.replace(re, repl_string);
    } else {
          const re = new RegExp(&quot;%userinfo%&quot;, &quot;g&quot;);
      return str.replace(re, userinfo.title_name);
    }
  };
  
  </code></pre>
  <p>I'm importing it in HomeTitle.tsx with <code>import { userInfoFill } from &quot;utils/userInfoFill&quot;;</code> I was wondering if netlify had issues with absolute paths being used but I'm not quite sure.</p>
  <p>My tsconfig.json looks like :</p>
  <pre><code>{
    &quot;compilerOptions&quot;: {
      &quot;target&quot;: &quot;es5&quot;,
      &quot;lib&quot;: [
        &quot;dom&quot;,
        &quot;dom.iterable&quot;,
        &quot;esnext&quot;
      ],
      &quot;allowJs&quot;: true,
      &quot;skipLibCheck&quot;: true,
      &quot;esModuleInterop&quot;: true,
      &quot;allowSyntheticDefaultImports&quot;: true,
      &quot;strict&quot;: true,
      &quot;forceConsistentCasingInFileNames&quot;: true,
      &quot;noFallthroughCasesInSwitch&quot;: true,
      &quot;module&quot;: &quot;esnext&quot;,
      &quot;moduleResolution&quot;: &quot;node&quot;,
      &quot;resolveJsonModule&quot;: true,
      &quot;isolatedModules&quot;: true,
      &quot;noEmit&quot;: true,
      &quot;jsx&quot;: &quot;react&quot;,
      &quot;baseUrl&quot;: &quot;src&quot;
    },
    &quot;include&quot;: [
      &quot;src&quot;
    ]
  }
  </code></pre>
  <p>Where adding <code>&quot;baseUrl&quot;: &quot;src&quot;</code> was taken from <a href="https://stackoverflow.com/questions/45213279/how-to-avoid-using-relative-path-imports-redux-action-action1-in-cre">this post</a>. To allow for absolute url references</p>
  <p>The file structure of the project is:</p>
  <pre><code>/
   ┣ client
   ┃ ┣ node_modules
   ┃ ┣ public
   ┃ ┣ src
   ┃ ┃ ┣ assets
   ┃ ┃ ┃ ┗ ...
   ┃ ┃ ┣ components
   ┃ ┃ ┃ ┗ ...
   ┃ ┃ ┣ containers
   ┃ ┃ ┃ ┣ home
   ┃ ┃ ┃ ┃ ┣ HomeTitle.tsx
   ┃ ┃ ┃ ┃ ┗ ...
   ┃ ┃ ┃ ┗ ...
   ┃ ┃ ┣ data
   ┃ ┃ ┃ ┣ temp
   ┃ ┃ ┃ ┃ ┗ ...
   ┃ ┃ ┃ ┣ userinfo.ts
   ┃ ┃ ┃ ┗ ...
   ┃ ┃ ┣ pages
   ┃ ┃ ┃ ┣ Home.tsx
   ┃ ┃ ┃ ┗ ...
   ┃ ┃ ┣ utils
   ┃ ┃ ┃ ┣ userInfoFill.ts
   ┃ ┃ ┃ ┣ userInfoFill.unit.test.ts
   ┃ ┃ ┃ ┗...
   ┃ ┃ ┣ App.tsx
   ┃ ┃ ┗ ...
   ┃ ┣ .eslintrc
   ┃ ┣ .tsconfig.json
   ┃ ┣ package.json
   ┃ ┗ ...
   ┣ server
   ┗ ...
  
  </code></pre>
  <p>I can build and host the server locally just fine so I'm not sure if there's some netlify setting I need?</p>
  <p>Here are my current build settings too:
  <a href="https://i.stack.imgur.com/45AaK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/45AaK.png" alt="Current netlify settings" /></a></p>