Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PM2 API connection error in Next.js 14: 'Module not found: Can't resolve term.js #5845

Open
arunpt opened this issue Jun 16, 2024 · 0 comments

Comments

@arunpt
Copy link

arunpt commented Jun 16, 2024

What's going wrong?

I was trying to utilize the pm2 API for a Next.js project, but when I imported it into the API directory and connected it, an exception was thrown: "Module not found: Can't resolve 'term.js'."

How could we reproduce this issue?

Create a nextjs 14 app using create-next-app and install pm2. After installation inside /app/api/test/route.ts write a simple route as below.

import { NextResponse } from "next/server";
import pm2 from "pm2";

export async function GET(request: Request) {
  pm2.connect((err) => console.log(err));
  return NextResponse.json({});
}

Traceback

  ▲ Next.js 14.2.4
  - Local:        http://localhost:3000

 ✓ Starting...
 ✓ Ready in 4.3s
 ○ Compiling /api/process/all ...
 ⨯ ./node_modules/blessed/lib/widgets/terminal.js:93:1
Module not found: Can't resolve 'term.js'

https://nextjs.org/docs/messages/module-not-found     

Import trace for requested module:
./node_modules/blessed/lib/widgets/ sync ^\.\/.*$     
./node_modules/blessed/lib/widget.js
./node_modules/blessed/lib/blessed.js
./node_modules/pm2/lib/API/Dashboard.js
./node_modules/pm2/lib/API/Extra.js
./node_modules/pm2/lib/API.js
./node_modules/pm2/index.js
./app/api/process/all/route.ts

Supporting information

OS: windows 10
NodeJS: v20.11.1
yarn: 1.22.22
next: 14.2.4
pm2: ^5.4.0
typescript: ^5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant