Module not found (Not a casing issue)

My nextjs site relies on these two dependencies and it works just fine locally but not when I deploy it live? They are both installed locally via npm. Here is the full repo if it helps

Site name: warm-valkyrie-b69040
Full build log:

12:31:17 PM: Failed during stage β€˜building site’: Build script returned non-zero exit code: 2
12:30:29 PM: build-image version: 8205490ca60064f5c9949f585e9e35b434be95b8 (focal)
12:30:29 PM: buildbot version: eb0b3c03ee1b40888f6883e255e3a141a5a683be
12:30:29 PM: Fetching cached dependencies
12:30:29 PM: Failed to fetch cache, continuing with build
12:30:29 PM: Starting to prepare the repo for build
12:30:30 PM: No cached dependencies found. Cloning fresh repo
12:30:30 PM: git clone --filter=blob:none GitHub - OblivionNoirV2/portfolio_next_version: This is the one that will be finalized
12:30:30 PM: Preparing Git Reference refs/heads/main
12:30:32 PM: Starting to install dependencies
12:30:32 PM: Python version set to 3.8
12:30:33 PM: Attempting Ruby version 2.7.2, read from environment
12:30:33 PM: Using Ruby version 2.7.2
12:30:34 PM: Started restoring cached go cache
12:30:34 PM: Finished restoring cached go cache
12:30:34 PM: go version go1.19.12 linux/amd64
12:30:34 PM: Using PHP version 8.0
12:30:35 PM: v18.17.1 is already installed.
12:30:36 PM: Now using node v18.17.1 (npm v9.6.7)
12:30:36 PM: Enabling Node.js Corepack
12:30:36 PM: Started restoring cached build plugins
12:30:36 PM: Finished restoring cached build plugins
12:30:36 PM: Started restoring cached corepack dependencies
12:30:36 PM: Finished restoring cached corepack dependencies
12:30:36 PM: No npm workspaces detected
12:30:36 PM: Started restoring cached node modules
12:30:36 PM: Finished restoring cached node modules
12:30:36 PM: Installing npm packages using npm version 9.6.7
12:30:43 PM: added 353 packages, and audited 354 packages in 6s
12:30:43 PM: 133 packages are looking for funding
12:30:43 PM: run npm fund for details
12:30:43 PM: found 0 vulnerabilities
12:30:43 PM: npm packages installed
12:30:43 PM: Install dependencies script success
12:30:43 PM: Starting build script
12:30:44 PM: Detected 1 framework(s)
12:30:44 PM: next at version 13.4.12
12:30:44 PM: Section completed: initializing
12:30:45 PM: ​
12:30:45 PM: Netlify Build
12:30:45 PM: ────────────────────────────────────────────────────────────────
12:30:45 PM: ​
12:30:45 PM: ❯ Version
12:30:45 PM: @netlify/build 29.20.11
12:30:45 PM: ​
12:30:45 PM: ❯ Flags
12:30:45 PM: baseRelDir: true
12:30:45 PM: buildId: 64ef7cb435877f00071c182c
12:30:45 PM: deployId: 64ef7cb435877f00071c182e
12:30:46 PM: ​
12:30:46 PM: ❯ Current directory
12:30:46 PM: /opt/build/repo
12:30:46 PM: ​
12:30:46 PM: ❯ Config file
12:30:46 PM: No config file was defined: using default values.
12:30:46 PM: ​
12:30:46 PM: ❯ Context
12:30:46 PM: production
12:30:46 PM: ​
12:30:46 PM: ❯ Installing plugins
12:30:46 PM: - @netlify/plugin-nextjs@4.40.1
12:30:58 PM: ​
12:30:58 PM: ❯ Using Next.js Runtime - v4.40.1
12:30:59 PM: ​
12:30:59 PM: @netlify/plugin-nextjs (onPreBuild event)
12:30:59 PM: ────────────────────────────────────────────────────────────────
12:30:59 PM: ​
12:30:59 PM: No Next.js cache to restore.
12:30:59 PM: Netlify configuration property build.environment.NEXT_PRIVATE_TARGET value changed.
12:30:59 PM: ​
12:30:59 PM: (@netlify/plugin-nextjs onPreBuild completed in 36ms)
12:30:59 PM: ​
12:30:59 PM: Build command from Netlify app
12:30:59 PM: ────────────────────────────────────────────────────────────────
12:30:59 PM: ​
12:30:59 PM: $ npm run build
12:31:00 PM: > portfoliov2@0.1.0 build
12:31:00 PM: > next build
12:31:00 PM: - warn No build cache found. Please configure build caching for faster rebuilds. Read more: No Cache Detected | Next.js
12:31:00 PM: - info Creating an optimized production build…
12:31:01 PM: Warning: For production Image Optimization with Next.js, the optional β€˜sharp’ package is strongly recommended. Run β€˜yarn add sharp’, and Next.js will use it automatically for Image Optimization.
12:31:01 PM: Read more: Sharp Missing In Production | Next.js
12:31:16 PM: Failed to compile.
12:31:16 PM:
12:31:16 PM: ./src/app/contact/page.tsx
12:31:16 PM: Module not found: Can’t resolve β€˜@emailjs/browser’
12:31:16 PM: Module Not Found | Next.js
12:31:16 PM: ./src/app/projects/page.tsx
12:31:16 PM: Module not found: Can’t resolve β€˜animejs/lib/anime.es.js’
12:31:16 PM: Module Not Found | Next.js
12:31:16 PM: > Build failed because of webpack errors
12:31:16 PM: ​
12:31:16 PM: build.command failed
12:31:16 PM: ────────────────────────────────────────────────────────────────
12:31:16 PM: ​
12:31:16 PM: Error message
12:31:16 PM: Command failed with exit code 1: npm run build
12:31:16 PM: ​
12:31:16 PM: Error location
12:31:16 PM: In Build command from Netlify app:
12:31:16 PM: npm run build
12:31:16 PM: ​
12:31:16 PM: Resolved config
12:31:16 PM: build:
12:31:16 PM: command: npm run build
12:31:16 PM: commandOrigin: ui
12:31:16 PM: environment:
12:31:16 PM: - API_KEY
12:31:16 PM: - NEXT_PRIVATE_TARGET
12:31:16 PM: publish: /opt/build/repo/.next
12:31:16 PM: publishOrigin: ui
12:31:16 PM: plugins:
12:31:16 PM: - inputs: {}
12:31:16 PM: origin: ui
12:31:16 PM: package: β€˜@netlify/plugin-nextjs’
12:31:17 PM: Caching artifacts
12:31:17 PM: Started saving node modules
12:31:17 PM: Finished saving node modules
12:31:17 PM: Started saving build plugins
12:31:17 PM: Finished saving build plugins
12:31:17 PM: Started saving corepack cache
12:31:17 PM: Finished saving corepack cache
12:31:17 PM: Started saving pip cache
12:31:17 PM: Finished saving pip cache
12:31:17 PM: Started saving emacs cask dependencies
12:31:17 PM: Finished saving emacs cask dependencies
12:31:17 PM: Started saving maven dependencies
12:31:17 PM: Finished saving maven dependencies
12:31:17 PM: Started saving boot dependencies
12:31:17 PM: Finished saving boot dependencies
12:31:17 PM: Started saving rust rustup cache
12:31:17 PM: Finished saving rust rustup cache
12:31:17 PM: Started saving go dependencies
12:31:17 PM: Finished saving go dependencies
12:31:17 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
12:31:17 PM: Failing build: Failed to build site
12:31:18 PM: Finished processing build request in 48.573s

Hi @OblivionNoir, thanks for the post and welcome to the Netlify Support Forums.

The errors above occurred because you have not installed the packages emailjs/browser and animejs.
Your package.json file does not have both packages registered in the dependencies section hence both packages have not been installed.

Kindly install them via npm

  1. npm install @emailjs/browser
  2. npm install animejs

Let me know the outcome.

Thanks.

that fixed it, thanks

1 Like

@OblivionNoir, You welcome
Glad to know the suggestions helped to fix your problem.