Issue while deploying Nextjs app (! Failed to install Node modules.)

# Heroku Node.js npm Install Buildpack

14:58:48.839

``

14:58:48.839

- Installing node modules

14:58:49.339

- Using npm version10.2.3``

14:58:49.339

- Creating npm cache

14:58:49.339

- Configuring npm cache directory

14:58:49.589

- Runningnpm ci “–production=false”``

14:58:49.589

``

14:58:49.839

npm WARN config production Use–omit=dev instead.

14:58:53.850

npm notice

14:58:53.850

npm notice New minor version of npm available! 10.2.3 -> 10.4.0

14:58:53.850

npm notice Changelog: <https://github.com/npm/cli/releases/tag/v10.4.0>

14:58:53.850

npm notice Runnpm install -g npm@10.4.0 to update!

14:58:53.850

npm notice

14:58:53.850

npm ERR! code EUSAGE

14:58:53.850

npm ERR!

14:58:53.850

npm ERR!npm cican only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file withnpm install before continuing.

14:58:53.850

npm ERR!

14:58:53.850

npm ERR! Invalid: lock file's @mantine/hooks@7.4.2 does not satisfy @mantine/hooks@7.5.0

14:58:53.850

npm ERR! Missing: @mantine/hooks@7.4.2 from lock file

14:58:53.850

npm ERR! Invalid: lock file's y-prosemirror@1.0.20 does not satisfy y-prosemirror@1.2.2

14:58:53.850

npm ERR! Missing: y-prosemirror@1.0.20 from lock file

14:58:53.850

npm ERR!

14:58:53.850

npm ERR! Clean install a project

14:58:53.850

npm ERR!

14:58:53.850

npm ERR! Usage:

14:58:53.850

npm ERR! npm ci

14:58:53.850

npm ERR!

14:58:53.850

npm ERR! Options:

14:58:53.850

npm ERR! [--install-strategy <hoisted|nested|shallow|linked>] [--legacy-bundling]

14:58:53.850

npm ERR! [--global-style] [--omit <dev|optional|peer> [--omit <dev|optional|peer> ...]]

14:58:53.850

npm ERR! [--include <prod|dev|optional|peer> [--include <prod|dev|optional|peer> ...]]

14:58:53.850

npm ERR! [--strict-peer-deps] [--foreground-scripts] [--ignore-scripts] [--no-audit]

14:58:53.850

npm ERR! [--no-bin-links] [--no-fund] [--dry-run]

14:58:53.850

npm ERR! [-w|--workspace <workspace-name> [-w|--workspace <workspace-name> ...]]

14:58:53.850

npm ERR! [-ws|--workspaces] [--include-workspace-root] [--install-links]

14:58:53.850

npm ERR!

14:58:53.850

npm ERR! aliases: clean-install, ic, install-clean, isntall-clean

14:58:53.850

npm ERR!

14:58:53.850

npm ERR! Run "npm help ci" for more info

14:58:53.850

14:58:53.850

npm ERR! A complete log of this run can be found in: /layers/heroku_nodejs-npm-install/npm_cache/_logs/2024-02-11T14_58_49_664Z-debug-0.log

14:58:53.850

14:58:53.850

- Done (4.104s)

14:58:53.850

- Debug info

14:58:53.850

- Command failednpm ci “–production=false”``

14:58:53.850

exit status: 1

14:58:53.850

stdout: <see above>

14:58:53.850

stderr: <see above>

14:58:53.850

``

14:58:53.850

! Failed to install Node modules.

14:58:53.850

!

14:58:53.850

! The Heroku Node.js npm Install Buildpackuses the commandnpm ci “–production=false” to install your Node modules. This command failed and the buildpack cannot continue. See the log output above for more information.

14:58:53.850

!

14:58:53.850

! This error can occur due to an unstable network connection. Ensure that this command runs locally without error (exit status = 0) and retry your build.

14:58:53.850

!

14:58:53.850

! If that doesn’t help, check the status of the upstream Node module repository service at https://status.npmjs.org/.

14:58:53.850

``

14:58:53.850

ERROR: failed to build: exit status 1

14:58:53.850

exit status 51

Hello,

It seems that you have a couple of errors related to your package-lock.json file:

npm ci can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with npm install before continuing.

Invalid: lock file's @mantine/hooks@7.4.2 does not satisfy @mantine/hooks@7.5.0
Missing: @mantine/hooks@7.4.2 from lock file
Invalid: lock file's y-prosemirror@1.0.20 does not satisfy y-prosemirror@1.2.2
Missing: y-prosemirror@1.0.20 from lock file
```

Updating locally your lock file before pushing should solve this issue.

Bastien

In my case it was flag: “legacy-peer-deps=true” in “~/.npmrc” file, setting it to false and running “npm i” again solved the problem.