Cannot find module <filename> or its corresponding type declarations

  • Netlify site name: rococo-dango-a809ba.netlify.app
  • Build problems:

I am at a loss. I am able to build and run locally with no issues. I can manually deploy my local build to netlify and it runs without issue. I have matched netlifies node and npm version and no problem building. I have narrowed down the root cause to react-scripts version update. If I downgrade to 3.X.X it will build ok, but I need to update the script else I will have to downgrade my typescript version and will not be able to use other dependencies.

Appreciate any help on resolving this.

2:55:29 PM: Build ready to start
2:55:31 PM: build-image version: 72a309a113b53ef075815b129953617827965e48 (focal)
2:55:31 PM: build-image tag: v4.8.2
2:55:31 PM: buildbot version: 515e5c33287d8b909c004fcf2e460e8645e8c1c6
2:55:31 PM: Fetching cached dependencies
2:55:35 PM: Finished downloading cache in 4.609439367s
2:55:35 PM: Starting to extract cache
2:55:50 PM: Finished extracting cache in 14.185803935s
2:55:50 PM: Finished fetching cache in 18.845411871s
2:55:50 PM: Starting to prepare the repo for build
2:55:50 PM: Preparing Git Reference refs/heads/dev
2:55:51 PM: Parsing package.json dependencies
2:55:52 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'pigeon-frontend/build' versus 'build' in the Netlify UI
2:55:53 PM: Starting build script
2:55:53 PM: Installing dependencies
2:55:53 PM: Python version set to 2.7
2:55:53 PM: Started restoring cached node version
2:55:55 PM: Finished restoring cached node version
2:55:55 PM: Attempting node version '14' from .nvmrc
2:55:55 PM: v14.19.3 is already installed.
2:55:55 PM: Now using node v14.19.3 (npm v6.14.17)
2:55:55 PM: Started restoring cached build plugins
2:55:55 PM: Finished restoring cached build plugins
2:55:55 PM: Attempting ruby version 2.7.2, read from environment
2:55:56 PM: Using ruby version 2.7.2
2:55:57 PM: Using PHP version 8.0
2:55:57 PM: No npm workspaces detected
2:55:57 PM: Started restoring cached node modules
2:55:57 PM: Finished restoring cached node modules
2:55:57 PM: Installing NPM modules using NPM version 6.14.17
2:56:24 PM: npm WARN deprecated svgo@1.3.2: This SVGO version is no longer supported. Upgrade to v2.x.x.
2:56:24 PM: npm WARN deprecated stable@0.1.8: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility
2:56:52 PM: > core-js@3.23.3 postinstall /opt/build/repo/pigeon-frontend/node_modules/core-js
2:56:52 PM: > node -e "try{require('./postinstall')}catch(e){}"
2:56:53 PM: npm notice created a lockfile as package-lock.json. You should commit this file.
2:56:53 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^2.3.2 (node_modules/react-scripts/node_modules/fsevents):
2:56:53 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
2:56:53 PM: npm WARN airbnb-prop-types@2.16.0 requires a peer of react@^0.14 || ^15.0.0 || ^16.0.0-alpha but none is installed. You must install peer dependencies yourself.
2:56:53 PM: npm WARN bootstrap@4.6.1 requires a peer of popper.js@^1.16.1 but none is installed. You must install peer dependencies yourself.
2:56:53 PM: npm WARN react-native-get-random-values@1.8.0 requires a peer of react-native@>=0.56 but none is installed. You must install peer dependencies yourself.
2:56:53 PM: npm WARN @apideck/better-ajv-errors@0.3.6 requires a peer of ajv@>=8 but none is installed. You must install peer dependencies yourself.
2:56:53 PM: added 530 packages from 279 contributors, removed 615 packages, updated 510 packages, moved 22 packages and audited 2129 packages in 55.201s
2:56:54 PM: 194 packages are looking for funding
2:56:54 PM:   run `npm fund` for details
2:56:54 PM: found 8 vulnerabilities (1 moderate, 7 high)
2:56:54 PM:   run `npm audit fix` to fix them, or `npm audit` for details
2:56:54 PM: NPM modules installed
2:56:54 PM: Started restoring cached go cache
2:56:54 PM: Finished restoring cached go cache
2:56:54 PM: Installing Go version 1.16.5 (requested 1.16.5)
2:56:59 PM: unset GOOS;
2:56:59 PM: unset GOARCH;
2:56:59 PM: export GOROOT='/opt/buildhome/.gimme/versions/go1.16.5.linux.amd64';
2:56:59 PM: export PATH="/opt/buildhome/.gimme/versions/go1.16.5.linux.amd64/bin:${PATH}";
2:56:59 PM: go version >&2;
2:56:59 PM: export GIMME_ENV="/opt/buildhome/.gimme/env/go1.16.5.linux.amd64.env"
2:56:59 PM: go version go1.16.5 linux/amd64
2:56:59 PM: Installing missing commands
2:56:59 PM: Verify run directory
2:57:00 PM: ​
2:57:00 PM: ────────────────────────────────────────────────────────────────
2:57:00 PM:   Netlify Build                                                 
2:57:00 PM: ────────────────────────────────────────────────────────────────
2:57:00 PM: ​
2:57:00 PM: ❯ Version
2:57:00 PM:   @netlify/build 27.3.0
2:57:00 PM: ​
2:57:00 PM: ❯ Flags
2:57:00 PM:   baseRelDir: true
2:57:00 PM:   buildId: 62bca0212343c00008815eb5
2:57:00 PM:   deployId: 62bca0212343c00008815eb7
2:57:00 PM: ​
2:57:00 PM: ❯ Current directory
2:57:00 PM:   /opt/build/repo/pigeon-frontend
2:57:00 PM: ​
2:57:00 PM: ❯ Config file
2:57:00 PM:   No config file was defined: using default values.
2:57:00 PM: ​
2:57:00 PM: ❯ Context
2:57:00 PM:   production
2:57:00 PM: ​
2:57:00 PM: ❯ Loading plugins
2:57:00 PM:    - @sentry/netlify-build-plugin@1.1.1 from Netlify app
2:57:01 PM: ​
2:57:01 PM: ────────────────────────────────────────────────────────────────
2:57:01 PM:   1. Build command from Netlify app                             
2:57:01 PM: ────────────────────────────────────────────────────────────────
2:57:01 PM: ​
2:57:01 PM: $ npm run build
2:57:02 PM: > pigeon-frontend@3.0.0 build /opt/build/repo/pigeon-frontend
2:57:02 PM: > react-scripts build
2:57:04 PM: Creating an optimized production build...
2:58:52 PM: Failed to compile.
2:58:52 PM: 
2:58:52 PM: TS2307: Cannot find module './AutocompleteOptions.module.scss' or its corresponding type declarations.
2:58:52 PM:     1 | import { Card } from 'react-bootstrap'
2:58:52 PM:     2 | import React from 'react'
2:58:52 PM:   > 3 | import classes from './AutocompleteOptions.module.scss'
2:58:52 PM:       |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2:58:52 PM:     4 |
2:58:52 PM:     5 | export const AutocompleteOptions = ({ data, status, handleSelect }) => {
2:58:52 PM:     6 |     const renderSuggestions = () =>
2:58:52 PM: npm ERR! code ELIFECYCLE
2:58:52 PM: npm ERR! errno 1
2:58:52 PM: npm ERR! pigeon-frontend@3.0.0 build: `react-scripts build`
2:58:52 PM: npm ERR! Exit status 1
2:58:52 PM: npm ERR!
2:58:52 PM: npm ERR! Failed at the pigeon-frontend@3.0.0 build script.
2:58:52 PM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2:58:52 PM: npm ERR! A complete log of this run can be found in:
2:58:52 PM: npm ERR!     /opt/buildhome/.npm/_logs/2022-06-29T18_58_52_560Z-debug.log
2:58:52 PM: ​
2:58:52 PM: ────────────────────────────────────────────────────────────────
2:58:52 PM:   "build.command" failed                                        
2:58:52 PM: ────────────────────────────────────────────────────────────────
2:58:52 PM: ​
2:58:52 PM:   Error message
2:58:52 PM:   Command failed with exit code 1: npm run build (https://ntl.fyi/exit-code-1)
2:58:52 PM: ​
2:58:52 PM:   Error location
2:58:52 PM:   In Build command from Netlify app:
2:58:52 PM:   npm run build
2:58:52 PM: ​
2:58:52 PM:   Resolved config
2:58:52 PM:   build:
2:58:52 PM:     base: /opt/build/repo/pigeon-frontend
2:58:52 PM:     command: npm run build
2:58:52 PM:     commandOrigin: ui
2:58:52 PM:     environment:
2:58:52 PM:       - NODE_OPTIONS
2:58:52 PM:       - ONEGRAPH_AUTHLIFY_TOKEN
2:58:52 PM:       - REACT_APP_COGNITO_CLIENT_ID
2:58:52 PM:       - REACT_APP_COGNITO_USER_POOL_ID
2:58:52 PM:       - REACT_APP_ENVIRONMENT
2:58:52 PM:       - REACT_APP_GOOGLE_MAPS_KEY
2:58:52 PM:       - REACT_APP_HELLO_SIGN_CLIENT_ID
2:58:52 PM:       - REACT_APP_PIGEON_API_URL
2:58:52 PM:       - REACT_APP_PIGEON_BASE_URL
2:58:52 PM:       - REACT_APP_STRIPE_API_KEY
2:58:52 PM:       - REACT_APP_STRIPE_CLIENT_ID
2:58:52 PM:       - SENTRY_AUTH_TOKEN
2:58:52 PM:       - SENTRY_ORG
2:58:52 PM:       - SENTRY_PROJECT
2:58:52 PM:     publish: /opt/build/repo/pigeon-frontend/build
2:58:52 PM:     publishOrigin: ui
2:58:52 PM:   plugins:
2:58:52 PM:     - inputs: {}
2:58:52 PM:       origin: ui
2:58:52 PM:       package: '@sentry/netlify-build-plugin'
2:58:53 PM: Caching artifacts
2:58:53 PM: Started saving node modules
2:58:53 PM: Finished saving node modules
2:58:53 PM: Started saving build plugins
2:58:53 PM: Finished saving build plugins
2:58:53 PM: Started saving pip cache
2:58:53 PM: Finished saving pip cache
2:58:53 PM: Started saving emacs cask dependencies
2:58:53 PM: Finished saving emacs cask dependencies
2:58:53 PM: Started saving maven dependencies
2:58:53 PM: Finished saving maven dependencies
2:58:53 PM: Started saving boot dependencies
2:58:53 PM: Finished saving boot dependencies
2:58:53 PM: Started saving rust rustup cache
2:58:53 PM: Finished saving rust rustup cache
2:58:53 PM: Started saving go dependencies
2:58:53 PM: Finished saving go dependencies
2:58:53 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
2:58:53 PM: Creating deploy upload records
2:58:53 PM: Failing build: Failed to build site
2:58:53 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
2:58:53 PM: Finished processing build request in 3m22.404131378s

Was able to resolve the issue by downgrading react-scripts from 5.0.1 to 4.0.3.

Have you declared types for *.scss:

In any case, if a library version upgrade/downgrade is causing/fixing issues, the problem appears to be with that library instead of Netlify. Especially since it’s a major version, have you checked the migration guide?

Is this related: