Common causes
- A missing or extra comma, bracket, parenthesis, or semicolon
- Using modern JavaScript syntax (optional chaining, nullish coalescing) in an older Node.js version
- A JSON file has a trailing comma or syntax error and is being required
- Copy-pasted code with invisible unicode characters or smart quotes
How to fix it
- Look at the line and column number in the error and check the code around it
- Check for mismatched brackets or parentheses
- Upgrade Node.js if using modern syntax: nvm use --lts
- Validate JSON files with: node -e "JSON.parse(require('fs').readFileSync('file.json','utf8'))"
Example
SyntaxError: Unexpected token ','
at wrapSafe (node:internal/modules/cjs/loader:1383:16)
at Module._compile (node:internal/modules/cjs/loader:1425:27)Requiring a JSON file that contains a trailing comma after the last property
Have a different error?
Paste any error message into the Error Translator to get an instant explanation.
