Netlify not deploying anymore. Module not found and typescript @types error

Hi I deployed my site on my domain, leye.dev (with Netlify), leyedev.netlfiy.app and leyedev.vercel.app. All these deploy on develop and main branch.

All these launched fine at my first push but now Netfliy initially gave an error because I was using import Header from “@/components/Header”. Since then I have changed all paths to absolute paths.
Now the Error I’m getting is concerning installing typescript and types/nodes. I have installed both of these and not sure why I’m still getting this error.
Please help

This deploys on my Vercel fine as the same branch push pushes to Vercel as well. But Errors on Netlify

Deployment Error

9:41:00 PM: build-image version: ecdc8b770f4a0193fd3f258c1bc6029e681813a4 (focal)
9:41:00 PM: buildbot version: 22552e71c3c7b6a5ebfd780eb1c9b2f42fe63aa7
9:41:00 PM: Fetching cached dependencies
9:41:00 PM: Starting to download cache of 283.3MB
9:41:02 PM: Finished downloading cache in 1.876s
9:41:02 PM: Starting to extract cache
9:41:05 PM: Finished extracting cache in 3.53s
9:41:05 PM: Finished fetching cache in 5.461s
9:41:05 PM: Starting to prepare the repo for build
9:41:06 PM: Preparing Git Reference pull/20/head
9:41:08 PM: Starting to install dependencies
9:41:08 PM: Python version set to 3.8
9:41:08 PM: Attempting Ruby version 2.7.2, read from environment
9:41:09 PM: Using Ruby version 2.7.2
9:41:10 PM: Started restoring cached go cache
9:41:10 PM: Finished restoring cached go cache
9:41:11 PM: go version go1.19.13 linux/amd64
9:41:12 PM: Using PHP version 8.0
9:41:13 PM: Started restoring cached Node.js version
9:41:14 PM: Finished restoring cached Node.js version
9:41:14 PM: v18.20.4 is already installed.
9:41:14 PM: Now using node v18.20.4 (npm v10.7.0)
9:41:14 PM: Enabling Node.js Corepack
9:41:14 PM: Started restoring cached build plugins
9:41:14 PM: Finished restoring cached build plugins
9:41:14 PM: WARNING: The environment variable 'NODE_ENV' is set to 'production'. Any 'devDependencies' in package.json will not be installed
9:41:14 PM: Started restoring cached corepack dependencies
9:41:14 PM: Finished restoring cached corepack dependencies
9:41:14 PM: No npm workspaces detected
9:41:14 PM: Started restoring cached node modules
9:41:14 PM: Finished restoring cached node modules
9:41:14 PM: Installing npm packages using npm version 10.7.0
9:41:15 PM: > leyeto-portfolio@0.1.0 postinstall
9:41:15 PM: > prisma generate
9:41:16 PM: Prisma schema loaded from prisma/schema.prisma
9:41:16 PM: ✔ Generated Prisma Client (v5.15.0) to ./node_modules/@prisma/client in 80ms
9:41:16 PM: Start using Prisma Client in Node.js (See: https://pris.ly/d/client)
9:41:16 PM: ```
import { PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()

9:41:16 PM: or start using Prisma Client at the edge (See: Prisma Accelerate | Prisma Documentation)
9:41:16 PM: ```
import { PrismaClient } from ‘@prisma/client/edge’
const prisma = new PrismaClient()

9:41:16 PM: See other ways of importing Prisma Client: http://pris.ly/d/importing-client
9:41:16 PM: ┌─────────────────────────────────────────────────────────────┐
9:41:16 PM: │  Deploying your app to serverless or edge functions?        │
9:41:16 PM: │  Try Prisma Accelerate for connection pooling and caching.  │
9:41:16 PM: │  https://pris.ly/cli/--accelerate                           │
9:41:16 PM: └─────────────────────────────────────────────────────────────┘
9:41:16 PM: added 3 packages, changed 3 packages, and audited 445 packages in 2s
9:41:16 PM: 53 packages are looking for funding
9:41:16 PM:   run `npm fund` for details
9:41:16 PM: found 0 vulnerabilities
9:41:16 PM: npm packages installed
9:41:17 PM: Successfully installed dependencies
9:41:17 PM: Starting build script
9:41:18 PM: Detected 1 framework(s)
9:41:18 PM: "next" at version "14.2.3"
9:41:18 PM: Section completed: initializing
Building
Failed
9:41:19 PM: Netlify Build                                                 
9:41:19 PM: ────────────────────────────────────────────────────────────────
9:41:19 PM: ​
9:41:19 PM: ❯ Version
9:41:19 PM:   @netlify/build 29.51.3
9:41:19 PM: ​
9:41:19 PM: ❯ Flags
9:41:19 PM:   baseRelDir: true
9:41:19 PM:   buildId: 66b138cf41d3eb00081158e9
9:41:19 PM:   deployId: 66b138cf41d3eb00081158eb
9:41:19 PM: ​
9:41:19 PM: ❯ Current directory
9:41:19 PM:   /opt/build/repo
9:41:19 PM: ​
9:41:19 PM: ❯ Config file
9:41:19 PM:   No config file was defined: using default values.
9:41:19 PM: ​
9:41:19 PM: ❯ Context
9:41:19 PM:   deploy-preview
9:41:21 PM: ​
9:41:21 PM: ❯ Using Next.js Runtime - v5.6.0
9:41:24 PM: Next.js cache restored
9:41:24 PM: ​
9:41:24 PM: Build command from Netlify app                                
9:41:24 PM: ────────────────────────────────────────────────────────────────
9:41:24 PM: ​
9:41:24 PM: $ npm run build
9:41:24 PM: > leyeto-portfolio@0.1.0 build
9:41:24 PM: > next build
9:41:25 PM:   ▲ Next.js 14.2.3
9:41:25 PM:    Creating an optimized production build ...
9:41:47 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
9:41:46 PM:  ✓ Compiled successfully
9:41:46 PM:    Skipping validation of types
9:41:46 PM:    Skipping linting
9:41:46 PM: It looks like you're trying to use TypeScript but do not have the required package(s) installed.
9:41:46 PM: Please install typescript and @types/node by running:
9:41:46 PM: 	npm install --save-dev typescript @types/node
9:41:46 PM: If you are not trying to use TypeScript, please remove the tsconfig.json file from your package root (and any TypeScript files in your pages directory).
9:41:47 PM: ​
9:41:47 PM: "build.command" failed                                        
9:41:47 PM: ────────────────────────────────────────────────────────────────
9:41:47 PM: ​
9:41:47 PM:   Error message
9:41:47 PM:   Command failed with exit code 1: npm run build (https://ntl.fyi/exit-code-1)
9:41:47 PM: ​
9:41:47 PM:   Error location
9:41:47 PM:   In Build command from Netlify app:
9:41:47 PM:   npm run build
9:41:47 PM: ​
9:41:47 PM:   Resolved config
9:41:47 PM:   build:
9:41:47 PM:     command: npm run build
9:41:47 PM:     commandOrigin: ui
9:41:47 PM:     environment:
9:41:47 PM:       - BREVO_ADD_CONTACT_API_KEY
9:41:47 PM:       - BREVO_MAIL_HOST
9:41:47 PM:       - BREVO_MAIL_PASSWORD
9:41:47 PM:       - BREVO_MAIL_PORT
9:41:47 PM:       - BREVO_MAIL_USER
9:41:47 PM:       - DATABASE_URL
9:41:47 PM:       - FORMSUBMIT_API_KEY
9:41:47 PM:       - NEXTAUTH_SECRET
9:41:47 PM:       - NEXTAUTH_URL
9:41:47 PM:       - NODE_ENV
9:41:47 PM:       - RECAPTCHA_SITE_KEY_PUBLIC
9:41:47 PM:       - RECAPTCHA_SITE_KEY_SECRET
9:41:47 PM:       - REVIEW_ID
9:41:47 PM:     publish: /opt/build/repo/.next
9:41:47 PM:     publishOrigin: ui
9:41:47 PM:   plugins:
9:41:47 PM:     - inputs: {}
9:41:47 PM:       origin: ui
9:41:47 PM:       package: '@netlify/plugin-nextjs'
9:41:47 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
9:41:47 PM: Failing build: Failed to build site
9:41:47 PM: Finished processing build request in 47.71s

tsconfig.json

{
  "compilerOptions": {
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "bundler",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve",
    "incremental": true,
    "plugins": [
      {
        "name": "next"
      }
    ],
    "baseUrl": ".",
    "paths": {
      "@": ["./"],
      "@/*": ["./*"],
      "@/components/*": ["./components/*"]
    }
  },
  "include": [
    "next-env.d.ts",
    "**/*.ts",
    "**/*.tsx",
    ".next/types/**/*.ts",
    "components/forms/ContactForm.tsx"
  ],
  "exclude": ["node_modules"]
}

package.json

{
  "name": "leyeto-portfolio",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start2": "next start",
    "start": "NODE_ENV=production node server.js",
    "lint": "next lint",
    "postinstall": "prisma generate"
  },
  "dependencies": {
    "@auth/prisma-adapter": "^2.1.0",
    "@ckeditor/ckeditor5-build-classic": "^41.4.2",
    "@ckeditor/ckeditor5-react": "^7.0.0",
    "@emotion/react": "^11.11.4",
    "@emotion/styled": "^11.11.5",
    "@fortawesome/fontawesome-svg-core": "^6.5.2",
    "@fortawesome/free-brands-svg-icons": "^6.5.2",
    "@fortawesome/react-fontawesome": "^0.2.2",
    "@mui/icons-material": "^5.15.18",
    "@mui/material": "^5.15.18",
    "@prisma/client": "^5.14.0",
    "@radix-ui/react-accordion": "^1.1.2",
    "@radix-ui/react-dialog": "^1.0.5",
    "@types/ckeditor": "^4.9.10",
    "bcryptjs": "^2.4.3",
    "class-variance-authority": "^0.7.0",
    "cloudinary": "^2.2.0",
    "clsx": "^2.1.1",
    "lucide-react": "^0.379.0",
    "mongodb": "^6.7.0",
    "next": "14.2.3",
    "next-auth": "^4.24.7",
    "nodemailer": "^6.9.14",
    "prisma": "^5.14.0",
    "react": "^18",
    "react-dom": "^18",
    "react-google-recaptcha-v3": "^1.10.1",
    "react-hook-form": "^7.52.1",
    "react-hot-toast": "^2.4.1",
    "react-slick": "^0.30.2",
    "react-typed": "^2.0.12",
    "slick-carousel": "^1.8.1",
    "tailwind-merge": "^2.3.0",
    "tailwindcss-animate": "^1.0.7",
    "zod": "^3.23.8"
  },
  "devDependencies": {
    "@types/bcryptjs": "^2.4.6",
    "@types/ckeditor__ckeditor5-core": "^33.0.3",
    "@types/node": "^20.14.14",
    "@types/nodemailer": "^6.4.15",
    "@types/react": "^18",
    "@types/react-dom": "^18",
    "@types/react-google-recaptcha": "^2.1.9",
    "@types/react-slick": "^0.23.13",
    "postcss": "^8",
    "tailwindcss": "^3.4.1",
    "typescript": "^5.5.4"
  }
}

Thank you very much in advance

Hi everyone I found a solution to my issue. I uninstalled @type/node and typescript as devdependencies and installed them as dependencies instead. Now works fine.

Not sure why this started creating errors but oh well.
Thanks

1 Like