运行Figma拼写检查器扩展报错:npm run build正常但spellcheck失败
Hey there, let's work through why your Figma spellchecker extension won't run even though npm run build completes successfully. Here are actionable steps to diagnose and fix the problem:
Verify the
spellcheckscript configuration inpackage.json
First, pop open yourpackage.jsonfile and check thescriptssection. Make sure thespellcheckcommand points to the correct script file with the right path. For example, if your spellcheck logic lives inscripts/spellcheck.js, the command should look like:"scripts": { "spellcheck": "node scripts/spellcheck.js" }Typos in the file path or command name are a super common culprit here.
Reinstall dependencies to rule out missing packages
Sometimesnpm run buildworks because it doesn't rely on the same dependencies as the spellcheck script. Runnpm installto refresh all your project dependencies. If your spellcheck uses specific libraries (likecspellor a custom spellcheck module), double-check that they're listed in eitherdependenciesordevDependenciesinpackage.json.Get detailed error logs to pinpoint the issue
The vague "console error" message isn't enough to diagnose the problem. Run the command with verbose logging to see the full error stack:npm run spellcheck --verboseAlternatively, try running the spellcheck script directly (e.g.,
node scripts/spellcheck.js) to see if it outputs more specific details—like a missing file, permission error, or code logic bug.Check the spellcheck script's logic and file paths
If you're using a custom spellcheck script, review its code to ensure it's correctly accessing your Figma extension's files. For example, if it's supposed to scan thedistfolder generated bynpm run build, confirm the path todistis correct in the script. Also, look for uncaught exceptions or missing variable declarations that might be crashing the script.Validate your build output structure
Even ifnpm run buildsucceeds, the output files might not match what the spellcheck script expects. Check thedist(or your build output) folder to confirm files are generated in the right location with the correct names. If the spellcheck script is looking for specific file types (like.tsxor.json), make sure those files exist in the build output.
内容的提问来源于stack exchange,提问作者Chris Northcutt

