Cannot find package 'vscode' imported from /dist/extension.js on Cursor IDE
Preflight Checklist
- [x] I have read the troubleshooting guide
- [x] I have searched existing issues and this is not a duplicate
- [x] This is a bug with the VS Code extension, not with how Prettier formats code
Issue Summary
When I try use prettier.prettier-vscode extension on cursor, Extension Host always thrown below error-logs.
2025-12-05 20:19:46.865 [error] Activating extension prettier.prettier-vscode failed due to an error:
2025-12-05 20:19:46.865 [error] Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'vscode' imported from /Users/USERNAME/.cursor/extensions/prettier.prettier-vscode-12.0.7-universal/dist/extension.js
at Object.getPackageJSONURL (node:internal/modules/package_json_reader:266:9)
at packageResolve (node:internal/modules/esm/resolve:779:81)
at moduleResolve (node:internal/modules/esm/resolve:865:18)
at defaultResolve (node:internal/modules/esm/resolve:995:11)
at nextResolve (node:internal/modules/esm/hooks:748:28)
at resolve (data:text/javascript;base64,CglleHBvcnQgYXN5bmMgZnVuY3Rpb24gcmVzb2x2ZShzcGVjaWZpZXIsIGNvbnRleHQsIG5leHRSZXNvbHZlKSB7CgkJaWYgKHNwZWNpZmllciA9PT0gJ2ZzJykgewoJCQlyZXR1cm4gewoJCQkJZm9ybWF0OiAnYnVpbHRpbicsCgkJCQlzaG9ydENpcmN1aXQ6IHRydWUsCgkJCQl1cmw6ICdub2RlOm9yaWdpbmFsLWZzJwoJCQl9OwoJCX0KCgkJLy8gRGVmZXIgdG8gdGhlIG5leHQgaG9vayBpbiB0aGUgY2hhaW4sIHdoaWNoIHdvdWxkIGJlIHRoZQoJCS8vIE5vZGUuanMgZGVmYXVsdCByZXNvbHZlIGlmIHRoaXMgaXMgdGhlIGxhc3QgdXNlci1zcGVjaWZpZWQgbG9hZGVyLgoJCXJldHVybiBuZXh0UmVzb2x2ZShzcGVjaWZpZXIsIGNvbnRleHQpOwoJfQ==:13:10)
at nextResolve (node:internal/modules/esm/hooks:748:28)
at resolve (/Applications/Cursor.app/Contents/Resources/app/node_modules/import-in-the-middle/hook.js:333:26)
at nextResolve (node:internal/modules/esm/hooks:748:28)
at Hooks.resolve (node:internal/modules/esm/hooks:240:30)
It seems Cursor-related issues, But I write this issues here for having same problem users
Version: 2.1.48
VSCode Version: 1.105.1
Commit: ce371ffbf5e240ca47f4b5f3f20efed084991120
Date: 2025-12-04T19:26:27.263Z (16 hrs ago)
Electron: 37.7.0
Chromium: 138.0.7204.251
Node.js: 22.20.0
V8: 13.8.258.32-electron.0
OS: Darwin arm64 25.1.0
Reproduction Repository
https://github.com/prettier/prettier-vscode
Steps to Reproduce
- Install prettier.prettier-vscode extension
- reload extension host
- Open Extension Host, It reproduced.
Expected Behavior
extension will be successfully activated
Actual Behavior
thrown error
Operating System
macOS
VS Code Version
1.105.1
Prettier Extension Version
12.0.7
Prettier Version
3.7.4
Prettier Extension Logs
2025-12-05 20:32:40.364 [error] Activating extension prettier.prettier-vscode failed due to an error:
2025-12-05 20:32:40.364 [error] Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'vscode' imported from /Users/USERNAME/.cursor/extensions/prettier.prettier-vscode-12.0.7-universal/dist/extension.js
at Object.getPackageJSONURL (node:internal/modules/package_json_reader:266:9)
at packageResolve (node:internal/modules/esm/resolve:779:81)
at moduleResolve (node:internal/modules/esm/resolve:865:18)
at defaultResolve (node:internal/modules/esm/resolve:995:11)
at nextResolve (node:internal/modules/esm/hooks:748:28)
at resolve (data:text/javascript;base64,CglleHBvcnQgYXN5bmMgZnVuY3Rpb24gcmVzb2x2ZShzcGVjaWZpZXIsIGNvbnRleHQsIG5leHRSZXNvbHZlKSB7CgkJaWYgKHNwZWNpZmllciA9PT0gJ2ZzJykgewoJCQlyZXR1cm4gewoJCQkJZm9ybWF0OiAnYnVpbHRpbicsCgkJCQlzaG9ydENpcmN1aXQ6IHRydWUsCgkJCQl1cmw6ICdub2RlOm9yaWdpbmFsLWZzJwoJCQl9OwoJCX0KCgkJLy8gRGVmZXIgdG8gdGhlIG5leHQgaG9vayBpbiB0aGUgY2hhaW4sIHdoaWNoIHdvdWxkIGJlIHRoZQoJCS8vIE5vZGUuanMgZGVmYXVsdCByZXNvbHZlIGlmIHRoaXMgaXMgdGhlIGxhc3QgdXNlci1zcGVjaWZpZWQgbG9hZGVyLgoJCXJldHVybiBuZXh0UmVzb2x2ZShzcGVjaWZpZXIsIGNvbnRleHQpOwoJfQ==:13:10)
at nextResolve (node:internal/modules/esm/hooks:748:28)
at resolve (/Applications/Cursor.app/Contents/Resources/app/node_modules/import-in-the-middle/hook.js:333:26)
at nextResolve (node:internal/modules/esm/hooks:748:28)
at Hooks.resolve (node:internal/modules/esm/hooks:240:30)
Prettier Configuration
{}
Reproduction Repository Required
Thanks for opening this issue! To help us investigate, we need a reproduction repository.
Why we need this
Most issues are configuration-specific. Without a repo we can clone and test, we usually cannot diagnose the problem.
How to create a reproduction
- Create a new public GitHub repository
- Add the minimum files needed to reproduce the issue
- Include a
.prettierrcor other config files you're using - Edit this issue and add the repository link
Tip: The simpler the reproduction, the faster we can help!
What happens next
- With a repo: We'll investigate and respond
- Without a repo: This issue will be automatically closed in 7 days
Resources
Most issues are configuration-specific. Without a repo we can clone and test, we usually cannot diagnose the problem.
I Agree, BTW This Issue reproduced any places (includes out of folders)
I did some investigating on my version of cursor (and got some assistance from Claude). It looks like this might be an ESM support issue in Cursor as the difference between this extension and other extensions appears to be that the ones that work are in CJS and this extension is in ESM.
The key here seems to be at resolve (/Applications/Cursor.app/Contents/Resources/app/node_modules/import-in-the-middle/hook.js:333:26) where it's trying to resolve "vscode" as an import rather than an engine.
Found this in Cursor that they haven't finished porting support for ESM yet - https://forum.cursor.com/t/cursor-2-1-seems-to-lack-esm-extension-support/144434
It's weird that VSCode-v1.104.00-based Google Antigravity supports ESM and works well with the new prettier extension while VSCode-v1.105.1-based Cursor does not.
I also asked Claude Code to fix the bundled extension files.
Show the fix
Windows
Save the following as fix-prettier-esm.ps1 in C:\Users\<USER>\.cursor\extensions\prettier.prettier-vscode-12.0.7-universal
Execute it with Powershell
# Fix Prettier VSCode 12.x ESM compatibility for Cursor
# Usage: Run this script in Prettier extension directory
$extDir = $PSScriptRoot
if (-not $extDir) { $extDir = Get-Location }
Write-Host "Fixing Prettier VSCode extension in: $extDir"
# 1. Fix package.json - remove "type": "module"
$pkgPath = Join-Path $extDir "package.json"
$pkg = Get-Content $pkgPath -Raw
$pkg = $pkg -replace '(\s*"license":\s*"MIT",)\s*\n\s*"type":\s*"module",', '$1'
Set-Content $pkgPath $pkg -NoNewline
Write-Host "[OK] package.json: removed 'type: module'"
# 2. Fix dist/extension.js - convert ESM to CommonJS
$extPath = Join-Path $extDir "dist\extension.js"
$content = Get-Content $extPath -Raw
# Replace all ESM imports with CommonJS requires
$replacements = @(
@('import \{ commands as commands2, workspace as workspace5 \} from "vscode";', 'const { commands: commands2, workspace: workspace5 } = require("vscode");'),
@('import \{ window \} from "vscode";', 'const { window } = require("vscode");'),
@('import \{ window as window2 \} from "vscode";', 'const { window: window2 } = require("vscode");'),
@('import \{ commands, Uri as Uri2, window as window3, workspace as workspace2 \} from "vscode";', 'const { commands, Uri: Uri2, window: window3, workspace: workspace2 } = require("vscode");'),
@('import \{ Uri, workspace \} from "vscode";', 'const { Uri, workspace } = require("vscode");'),
@('import \{ Uri as Uri4, workspace as workspace4 \} from "vscode";', 'const { Uri: Uri4, workspace: workspace4 } = require("vscode");'),
@('import \* as fs2 from "fs";', 'const fs2 = require("fs");'),
@('import \* as fs from "fs";', 'const fs = require("fs");'),
@('import \* as path6 from "path";', 'const path6 = require("path");'),
@('import \* as path from "path";', 'const path = require("path");'),
@('import \* as path2 from "path";', 'const path2 = require("path");'),
@('import \* as path3 from "path";', 'const path3 = require("path");'),
@('import \* as path4 from "path";', 'const path4 = require("path");'),
@('import \* as path5 from "path";', 'const path5 = require("path");'),
@('import \* as path7 from "path";', 'const path7 = require("path");'),
@('import \* as os from "os";', 'const os = require("os");'),
@('import \{ spawn \} from "child_process";', 'const { spawn } = require("child_process");'),
@('import \{ pathToFileURL as pathToFileURL2 \} from "url";', 'const { pathToFileURL: pathToFileURL2 } = require("url");'),
@('import \{ pathToFileURL as pathToFileURL3 \} from "url";', 'const { pathToFileURL: pathToFileURL3 } = require("url");'),
@('import \{ pathToFileURL \} from "url";', 'const { pathToFileURL } = require("url");'),
@('import \{ createRequire \} from "module";', 'const { createRequire } = require("module");'),
@('import \{ TextEncoder \} from "util";', 'const { TextEncoder } = require("util");')
)
foreach ($r in $replacements) {
$content = $content -replace $r[0], $r[1]
}
# Replace multiline vscode imports
$content = $content -replace 'import \{\s*languages as languages2,\s*Range as Range2,\s*TextEdit as TextEdit2,\s*window as window5,\s*workspace as workspace3\s*\} from "vscode";', 'const { languages: languages2, Range: Range2, TextEdit: TextEdit2, window: window5, workspace: workspace3 } = require("vscode");'
$content = $content -replace 'import \{\s*CodeAction,\s*CodeActionKind,\s*WorkspaceEdit\s*\} from "vscode";', 'const { CodeAction, CodeActionKind, WorkspaceEdit } = require("vscode");'
$content = $content -replace 'import \{\s*languages,\s*LanguageStatusSeverity,\s*StatusBarAlignment,\s*ThemeColor,\s*window as window4\s*\} from "vscode";', 'const { languages, LanguageStatusSeverity, StatusBarAlignment, ThemeColor, window: window4 } = require("vscode");'
# Replace export with module.exports
$content = $content -replace 'export \{\s*activate\s*\};', 'module.exports = { activate };'
Set-Content $extPath $content -NoNewline
Write-Host "[OK] dist/extension.js: converted ESM to CommonJS"
Write-Host "`nDone! Restart Cursor to apply changes."
Linux / MacOS
cd ~/.cursor/extensions/prettier.prettier-vscode-12.0.7-universal
./fix-prettier-esm.sh
#!/bin/bash
# Fix Prettier VSCode 12.x ESM compatibility for Cursor
# Usage: Run this script in Prettier extension directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
EXT_DIR="${1:-$SCRIPT_DIR}"
echo "Fixing Prettier VSCode extension in: $EXT_DIR"
# 1. Fix package.json - remove "type": "module"
PKG_PATH="$EXT_DIR/package.json"
sed -i 's/"license": "MIT",\s*\n\s*"type": "module",/"license": "MIT",/' "$PKG_PATH" 2>/dev/null || \
sed -i '' 's/"license": "MIT",'"$(printf '\n\t')"'"type": "module",/"license": "MIT",/' "$PKG_PATH"
echo "[OK] package.json: removed 'type: module'"
# 2. Fix dist/extension.js - convert ESM to CommonJS
EXT_PATH="$EXT_DIR/dist/extension.js"
# Single line imports
sed -i 's/import { commands as commands2, workspace as workspace5 } from "vscode";/const { commands: commands2, workspace: workspace5 } = require("vscode");/g' "$EXT_PATH"
sed -i 's/import { window } from "vscode";/const { window } = require("vscode");/g' "$EXT_PATH"
sed -i 's/import { window as window2 } from "vscode";/const { window: window2 } = require("vscode");/g' "$EXT_PATH"
sed -i 's/import { commands, Uri as Uri2, window as window3, workspace as workspace2 } from "vscode";/const { commands, Uri: Uri2, window: window3, workspace: workspace2 } = require("vscode");/g' "$EXT_PATH"
sed -i 's/import { Uri, workspace } from "vscode";/const { Uri, workspace } = require("vscode");/g' "$EXT_PATH"
sed -i 's/import { Uri as Uri4, workspace as workspace4 } from "vscode";/const { Uri: Uri4, workspace: workspace4 } = require("vscode");/g' "$EXT_PATH"
# Node.js built-in modules
sed -i 's/import \* as fs2 from "fs";/const fs2 = require("fs");/g' "$EXT_PATH"
sed -i 's/import \* as fs from "fs";/const fs = require("fs");/g' "$EXT_PATH"
sed -i 's/import \* as path6 from "path";/const path6 = require("path");/g' "$EXT_PATH"
sed -i 's/import \* as path7 from "path";/const path7 = require("path");/g' "$EXT_PATH"
sed -i 's/import \* as path5 from "path";/const path5 = require("path");/g' "$EXT_PATH"
sed -i 's/import \* as path4 from "path";/const path4 = require("path");/g' "$EXT_PATH"
sed -i 's/import \* as path3 from "path";/const path3 = require("path");/g' "$EXT_PATH"
sed -i 's/import \* as path2 from "path";/const path2 = require("path");/g' "$EXT_PATH"
sed -i 's/import \* as path from "path";/const path = require("path");/g' "$EXT_PATH"
sed -i 's/import \* as os from "os";/const os = require("os");/g' "$EXT_PATH"
sed -i 's/import { spawn } from "child_process";/const { spawn } = require("child_process");/g' "$EXT_PATH"
sed -i 's/import { pathToFileURL as pathToFileURL2 } from "url";/const { pathToFileURL: pathToFileURL2 } = require("url");/g' "$EXT_PATH"
sed -i 's/import { pathToFileURL as pathToFileURL3 } from "url";/const { pathToFileURL: pathToFileURL3 } = require("url");/g' "$EXT_PATH"
sed -i 's/import { pathToFileURL } from "url";/const { pathToFileURL } = require("url");/g' "$EXT_PATH"
sed -i 's/import { createRequire } from "module";/const { createRequire } = require("module");/g' "$EXT_PATH"
sed -i 's/import { TextEncoder } from "util";/const { TextEncoder } = require("util");/g' "$EXT_PATH"
# Multiline vscode imports - use perl for multiline
perl -i -0pe 's/import \{\s*languages as languages2,\s*Range as Range2,\s*TextEdit as TextEdit2,\s*window as window5,\s*workspace as workspace3\s*\} from "vscode";/const { languages: languages2, Range: Range2, TextEdit: TextEdit2, window: window5, workspace: workspace3 } = require("vscode");/gs' "$EXT_PATH"
perl -i -0pe 's/import \{\s*CodeAction,\s*CodeActionKind,\s*WorkspaceEdit\s*\} from "vscode";/const { CodeAction, CodeActionKind, WorkspaceEdit } = require("vscode");/gs' "$EXT_PATH"
perl -i -0pe 's/import \{\s*languages,\s*LanguageStatusSeverity,\s*StatusBarAlignment,\s*ThemeColor,\s*window as window4\s*\} from "vscode";/const { languages, LanguageStatusSeverity, StatusBarAlignment, ThemeColor, window: window4 } = require("vscode");/gs' "$EXT_PATH"
# Replace export with module.exports
perl -i -0pe 's/export \{\s*activate\s*\};/module.exports = { activate };/gs' "$EXT_PATH"
echo "[OK] dist/extension.js: converted ESM to CommonJS"
echo ""
echo "Done! Restart Cursor to apply changes."