Next.js Discord

Discord Forum

follow redirects // debug.js Issue

Unanswered
Ghost ant posted this in #help-forum
Open in Discord
Ghost antOP
Hello everyone, i'ld like to share a small situation that i'ven't seen before, is this common?

yarn run v1.22.19
warning ../../package.json: No license field
$ next dev
warning ../../package.json: No license field
â–² Next.js 13.5.3
- Local: http://localhost:3000
- Environments: .env.local

✓ Ready in 4.1s
â—‹ Compiling /test/page ...
âš  ./node_modules/debug/src/node.js
Module not found: ESM packages (supports-color) need to be imported. Use 'import' to reference the package instead. https://nextjs.org/docs/messages/import-esm-externals

Import trace for requested module:
./node_modules/debug/src/node.js
./node_modules/debug/src/index.js
./node_modules/follow-redirects/debug.js
./node_modules/follow-redirects/index.js
./node_modules/axios/lib/adapters/http.js
./node_modules/axios/lib/adapters/adapters.js
./node_modules/axios/lib/axios.js
./node_modules/axios/index.js
./src/http/httpClient.ts
./src/network/appServer.api.ts
./src/app/test/components/TestServers/TestServers.ssr.tsx
./src/app/test/page.tsx

16 Replies

how are you importing supports-color in src/app/test/page.tsx (are you using require()?)
Ghost antOP
hi @riský that's the weirdest part of it, i'm not using it, first it was showing me that it was trying to import it in a node_module package, , installed it just cause tried to fix it, and then it show that error:
let me uninstall it so i can post the original error
here:
it's trying to import it for a module:
.
âš  ./node_modules/debug/src/node.js
Module not found: Can't resolve 'supports-color' in '/home/sabas/code/nextjs-nestjs-fullstack-app/client/web-app/node_modules/debug/src'
but i'm not running any dark lib:
{
"name": "web-app",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@tanstack/react-query": "^4.35.3",
"axios": "^1.5.1",
"debug": "^4.3.4",
"dotenv": "^16.3.1",
"next": "latest",
"react": "latest",
"react-dom": "latest",
"react-server-dom-webpack": "^0.0.1"
},
"devDependencies": {
"@types/axios": "^0.14.0",
"@types/node": "latest",
"@types/react": "latest",
"@types/react-dom": "latest",
"@types/react-query": "^1.2.9",
"typescript": "latest"
}
}
umm i haven't seen this before 😭 sorry
Ghost antOP
sorry i just recall this was my original issue:
@riský umm i haven't seen this before 😭 *sorry*
Ghost antOP
thanks tho!
Ghost antOP
found out how to fix the original error, by updating the nextConfig file (follow redirects // debug.js )

/** @type {import('next').NextConfig} */
const nextConfig = {
webpack: (config) => {
config.resolve.preferRelative = true;
return config;
},
}

module.exports = nextConfig;
ahh thats very nice
and what about the other issues?
Ghost antOP
those were failed attempts that i forgot i did
so what is the issue you are having now?
@Ghost ant hi <@657067112434499595> that's the weirdest part of it, i'm not using it, first it was showing me that it was trying to import it in a node_module package, , installed it just cause tried to fix it, and then it show that error:
It's a bug happening in my projects (Next Docs) too, the supports-color error seems won't affect much on my project.

Try installing supports-color@8.1.1 fixed the error for me