When tried to commit nextjs with nextauth, lint stage failed due to this error,
Explicitly specified file was ignored due to negative glob patterns: "c:/projects/project01/app/api/auth/[...nextauth]/route.ts".
lint stage config in package.json,
"lint-staged": {
"**/*": "prettier --write --ignore-unknown"
}
}
Is this error causing due to nextjs catch all route folder name with brackets?
i have a same case
and according to what I read, you have to use a terminal other than Windows to solve this
please read this prettier-isue
This document explains the steps you have taken so far in an attempt to reproduce an issue encountered with Prettier when dealing with files with special names.
Step 1: Creating the Test Project
npx create-next-app@latestto create a Next.js project.Step 2: Installing Prettier
Step 3: Creating a Test File
.src/pages/api/auth/[...nextauth].ts.Step 4: Attempting to Run Prettier
npx prettier --write "./src/pages/api/auth/[...nextauth].ts".[error] Explicitly specified file was ignored due to negative glob patterns: "./src/pages/api/auth/[...nextauth].ts"..Step 5: Attempting to Escape Special Characters
[...nextauth].tsusing different methods, including the caret ("^","`","") character in PowerShell.Step 6: Testing with Zsh Terminal
npx prettier --write ./src/pages/api/auth/\[...nextauth\].ts.Step 7: Testing with Custom Command
package.jsonfile:"format:fix": "prettier --write --ignore-path .gitignore ."npm run format:fixcommand successfully formats all target files, including[...nextauth].ts.Step 8: Conclusion
Unfortunately, the issue persists under Windows, even after multiple attempts to escape special characters in the
[...nextauth].tsfile name. Prettier continues to reject the file due to negative glob patterns.My setup
generated with:
System:
Binaries:
npmPackages:
additional informations
(does not work on Windows with these terminals)
It worked on