Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: unknown node type: Script #456

Open
hrishikesh-k opened this issue Aug 4, 2024 · 13 comments
Open

Error: unknown node type: Script #456

hrishikesh-k opened this issue Aug 4, 2024 · 13 comments

Comments

@hrishikesh-k
Copy link

Trying to add Prettier to my project: https://github.com/hrishikesh-k/blog. Running npx prettier . --write fails with the above error. Here's the entire output:

Terminal output
npx prettier . --write
package-lock.json 285ms (unchanged)
package.json 2ms (unchanged)
packages/adapter/index.ts 549ms (unchanged)
packages/adapter/package.json 2ms (unchanged)
packages/adapter/tsconfig.json 3ms (unchanged)
packages/archive/index.ts 31ms (unchanged)
packages/archive/package.json 1ms (unchanged)
packages/archive/tsconfig.json 4ms (unchanged)
packages/cache/index.ts 28ms (unchanged)
packages/cache/package.json 2ms (unchanged)
packages/cache/tsconfig.json 3ms (unchanged)
packages/image/index.ts 24ms (unchanged)
packages/image/package.json 2ms (unchanged)
packages/image/tsconfig.json 3ms (unchanged)
packages/site/deno/image.ts 21ms (unchanged)
packages/site/package.json 2ms (unchanged)
packages/site/postcss.config.js 18ms (unchanged)
packages/site/src/app.d.ts 17ms (unchanged)
packages/site/src/app.html 34ms (unchanged)
packages/site/src/components/c-button.svelte{
    "type": "Script",
    "start": 0,
    "end": 4615,
    "context": "default",
    "content": {
        "type": "Program",
        "start": 4604,
        "end": 4606,
        "loc": {
            "start": {
                "line": 1,
                "column": 0
            },
            "end": {
                "line": 1,
                "column": 4606
            }
        },
        "body": [
            {
                "type": "BlockStatement",
                "start": 4604,
                "end": 4606,
                "loc": {
                    "start": {
                        "line": 1,
                        "column": 4604
                    },
                    "end": {
                        "line": 1,
                        "column": 4606
                    }
                },
                "body": []
            }
        ],
        "sourceType": "module"
    }
}

[error] packages/site/src/components/c-button.svelte: Error: unknown node type: Script
[error]     at Object.print (/home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-svelte/plugin.js:1474:11)
[error]     at Object.print (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-tailwindcss/dist/index.mjs:2353:59544)
[error]     at callPluginPrintFunction (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:20871:20)
[error]     at mainPrintInternal (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:20854:18)
[error]     at mainPrint (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:20837:14)
[error]     at AstPath.call (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:19316:14)
[error]     at printTopLevelParts (/home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-svelte/plugin.js:1515:33)
[error]     at Object.print (/home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-svelte/plugin.js:929:16)
[error]     at Object.print (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-tailwindcss/dist/index.mjs:2353:59544)
[error]     at callPluginPrintFunction (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:20871:20)
packages/site/src/components/c-icon.svelte{
    "type": "Script",
    "start": 0,
    "end": 363,
    "context": "default",
    "content": {
        "type": "Program",
        "start": 352,
        "end": 354,
        "loc": {
            "start": {
                "line": 1,
                "column": 0
            },
            "end": {
                "line": 1,
                "column": 354
            }
        },
        "body": [
            {
                "type": "BlockStatement",
                "start": 352,
                "end": 354,
                "loc": {
                    "start": {
                        "line": 1,
                        "column": 352
                    },
                    "end": {
                        "line": 1,
                        "column": 354
                    }
                },
                "body": []
            }
        ],
        "sourceType": "module"
    }
}

[error] packages/site/src/components/c-icon.svelte: Error: unknown node type: Script
[error]     at Object.print (/home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-svelte/plugin.js:1474:11)
[error]     at Object.print (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-tailwindcss/dist/index.mjs:2353:59544)
[error]     at callPluginPrintFunction (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:20871:20)
[error]     at mainPrintInternal (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:20854:18)
[error]     at mainPrint (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:20837:14)
[error]     at AstPath.call (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:19316:14)
[error]     at printTopLevelParts (/home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-svelte/plugin.js:1515:33)
[error]     at Object.print (/home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-svelte/plugin.js:929:16)
[error]     at Object.print (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-tailwindcss/dist/index.mjs:2353:59544)
[error]     at callPluginPrintFunction (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:20871:20)
packages/site/src/components/c-notion-code.svelte{
    "type": "Script",
    "start": 0,
    "end": 419,
    "context": "default",
    "content": {
        "type": "Program",
        "start": 408,
        "end": 410,
        "loc": {
            "start": {
                "line": 1,
                "column": 0
            },
            "end": {
                "line": 1,
                "column": 410
            }
        },
        "body": [
            {
                "type": "BlockStatement",
                "start": 408,
                "end": 410,
                "loc": {
                    "start": {
                        "line": 1,
                        "column": 408
                    },
                    "end": {
                        "line": 1,
                        "column": 410
                    }
                },
                "body": []
            }
        ],
        "sourceType": "module"
    }
}

[error] packages/site/src/components/c-notion-code.svelte: Error: unknown node type: Script
[error]     at Object.print (/home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-svelte/plugin.js:1474:11)
[error]     at Object.print (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-tailwindcss/dist/index.mjs:2353:59544)
[error]     at callPluginPrintFunction (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:20871:20)
[error]     at mainPrintInternal (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:20854:18)
[error]     at mainPrint (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:20837:14)
[error]     at AstPath.call (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:19316:14)
[error]     at printTopLevelParts (/home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-svelte/plugin.js:1515:33)
[error]     at Object.print (/home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-svelte/plugin.js:929:16)
[error]     at Object.print (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-tailwindcss/dist/index.mjs:2353:59544)
[error]     at callPluginPrintFunction (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:20871:20)
packages/site/src/components/c-notion-image.svelte{
    "type": "Script",
    "start": 0,
    "end": 799,
    "context": "default",
    "content": {
        "type": "Program",
        "start": 788,
        "end": 790,
        "loc": {
            "start": {
                "line": 1,
                "column": 0
            },
            "end": {
                "line": 1,
                "column": 790
            }
        },
        "body": [
            {
                "type": "BlockStatement",
                "start": 788,
                "end": 790,
                "loc": {
                    "start": {
                        "line": 1,
                        "column": 788
                    },
                    "end": {
                        "line": 1,
                        "column": 790
                    }
                },
                "body": []
            }
        ],
        "sourceType": "module"
    }
}

[error] packages/site/src/components/c-notion-image.svelte: Error: unknown node type: Script
[error]     at Object.print (/home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-svelte/plugin.js:1474:11)
[error]     at Object.print (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-tailwindcss/dist/index.mjs:2353:59544)
[error]     at callPluginPrintFunction (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:20871:20)
[error]     at mainPrintInternal (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:20854:18)
[error]     at mainPrint (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:20837:14)
[error]     at AstPath.call (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:19316:14)
[error]     at printTopLevelParts (/home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-svelte/plugin.js:1515:33)
[error]     at Object.print (/home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-svelte/plugin.js:929:16)
[error]     at Object.print (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-tailwindcss/dist/index.mjs:2353:59544)
[error]     at callPluginPrintFunction (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:20871:20)
packages/site/src/components/c-tooltip.svelte{
    "type": "Script",
    "start": 0,
    "end": 963,
    "context": "default",
    "content": {
        "type": "Program",
        "start": 952,
        "end": 954,
        "loc": {
            "start": {
                "line": 1,
                "column": 0
            },
            "end": {
                "line": 1,
                "column": 954
            }
        },
        "body": [
            {
                "type": "BlockStatement",
                "start": 952,
                "end": 954,
                "loc": {
                    "start": {
                        "line": 1,
                        "column": 952
                    },
                    "end": {
                        "line": 1,
                        "column": 954
                    }
                },
                "body": []
            }
        ],
        "sourceType": "module"
    }
}

[error] packages/site/src/components/c-tooltip.svelte: Error: unknown node type: Script
[error]     at Object.print (/home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-svelte/plugin.js:1474:11)
[error]     at Object.print (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-tailwindcss/dist/index.mjs:2353:59544)
[error]     at callPluginPrintFunction (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:20871:20)
[error]     at mainPrintInternal (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:20854:18)
[error]     at mainPrint (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:20837:14)
[error]     at AstPath.call (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:19316:14)
[error]     at printTopLevelParts (/home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-svelte/plugin.js:1515:33)
[error]     at Object.print (/home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-svelte/plugin.js:929:16)
[error]     at Object.print (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-tailwindcss/dist/index.mjs:2353:59544)
[error]     at callPluginPrintFunction (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:20871:20)
packages/site/src/lib/constants.ts 14ms (unchanged)
packages/site/src/lib/functions.ts 19ms (unchanged)
packages/site/src/lib/server/constants.ts 36ms (unchanged)
packages/site/src/lib/server/functions.ts 37ms
packages/site/src/lib/types.ts 38ms (unchanged)
packages/site/src/partials/p-animation/p-animation.svelte{
    "type": "Script",
    "start": 0,
    "end": 29087,
    "context": "default",
    "content": {
        "type": "Program",
        "start": 29076,
        "end": 29078,
        "loc": {
            "start": {
                "line": 1,
                "column": 0
            },
            "end": {
                "line": 1,
                "column": 29078
            }
        },
        "body": [
            {
                "type": "BlockStatement",
                "start": 29076,
                "end": 29078,
                "loc": {
                    "start": {
                        "line": 1,
                        "column": 29076
                    },
                    "end": {
                        "line": 1,
                        "column": 29078
                    }
                },
                "body": []
            }
        ],
        "sourceType": "module"
    }
}

[error] packages/site/src/partials/p-animation/p-animation.svelte: Error: unknown node type: Script
[error]     at Object.print (/home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-svelte/plugin.js:1474:11)
[error]     at Object.print (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-tailwindcss/dist/index.mjs:2353:59544)
[error]     at callPluginPrintFunction (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:20871:20)
[error]     at mainPrintInternal (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:20854:18)
[error]     at mainPrint (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:20837:14)
[error]     at AstPath.call (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:19316:14)
[error]     at printTopLevelParts (/home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-svelte/plugin.js:1515:33)
[error]     at Object.print (/home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-svelte/plugin.js:929:16)
[error]     at Object.print (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-tailwindcss/dist/index.mjs:2353:59544)
[error]     at callPluginPrintFunction (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:20871:20)
packages/site/src/partials/p-animation/p-svg-group.svelte{
    "type": "Script",
    "start": 0,
    "end": 423,
    "context": "default",
    "content": {
        "type": "Program",
        "start": 412,
        "end": 414,
        "loc": {
            "start": {
                "line": 1,
                "column": 0
            },
            "end": {
                "line": 1,
                "column": 414
            }
        },
        "body": [
            {
                "type": "BlockStatement",
                "start": 412,
                "end": 414,
                "loc": {
                    "start": {
                        "line": 1,
                        "column": 412
                    },
                    "end": {
                        "line": 1,
                        "column": 414
                    }
                },
                "body": []
            }
        ],
        "sourceType": "module"
    }
}

[error] packages/site/src/partials/p-animation/p-svg-group.svelte: Error: unknown node type: Script
[error]     at Object.print (/home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-svelte/plugin.js:1474:11)
[error]     at Object.print (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-tailwindcss/dist/index.mjs:2353:59544)
[error]     at callPluginPrintFunction (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:20871:20)
[error]     at mainPrintInternal (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:20854:18)
[error]     at mainPrint (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:20837:14)
[error]     at AstPath.call (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:19316:14)
[error]     at printTopLevelParts (/home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-svelte/plugin.js:1515:33)
[error]     at Object.print (/home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-svelte/plugin.js:929:16)
[error]     at Object.print (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-tailwindcss/dist/index.mjs:2353:59544)
[error]     at callPluginPrintFunction (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:20871:20)
packages/site/src/partials/p-header.svelte{
    "type": "Script",
    "start": 0,
    "end": 327,
    "context": "default",
    "content": {
        "type": "Program",
        "start": 316,
        "end": 318,
        "loc": {
            "start": {
                "line": 1,
                "column": 0
            },
            "end": {
                "line": 1,
                "column": 318
            }
        },
        "body": [
            {
                "type": "BlockStatement",
                "start": 316,
                "end": 318,
                "loc": {
                    "start": {
                        "line": 1,
                        "column": 316
                    },
                    "end": {
                        "line": 1,
                        "column": 318
                    }
                },
                "body": []
            }
        ],
        "sourceType": "module"
    }
}

[error] packages/site/src/partials/p-header.svelte: Error: unknown node type: Script
[error]     at Object.print (/home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-svelte/plugin.js:1474:11)
[error]     at Object.print (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-tailwindcss/dist/index.mjs:2353:59544)
[error]     at callPluginPrintFunction (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:20871:20)
[error]     at mainPrintInternal (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:20854:18)
[error]     at mainPrint (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:20837:14)
[error]     at AstPath.call (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:19316:14)
[error]     at printTopLevelParts (/home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-svelte/plugin.js:1515:33)
[error]     at Object.print (/home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-svelte/plugin.js:929:16)
[error]     at Object.print (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-tailwindcss/dist/index.mjs:2353:59544)
[error]     at callPluginPrintFunction (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:20871:20)
packages/site/src/routes/+layout.svelte{
    "type": "Script",
    "start": 0,
    "end": 407,
    "context": "default",
    "content": {
        "type": "Program",
        "start": 396,
        "end": 398,
        "loc": {
            "start": {
                "line": 1,
                "column": 0
            },
            "end": {
                "line": 1,
                "column": 398
            }
        },
        "body": [
            {
                "type": "BlockStatement",
                "start": 396,
                "end": 398,
                "loc": {
                    "start": {
                        "line": 1,
                        "column": 396
                    },
                    "end": {
                        "line": 1,
                        "column": 398
                    }
                },
                "body": []
            }
        ],
        "sourceType": "module"
    }
}

[error] packages/site/src/routes/+layout.svelte: Error: unknown node type: Script
[error]     at Object.print (/home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-svelte/plugin.js:1474:11)
[error]     at Object.print (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-tailwindcss/dist/index.mjs:2353:59544)
[error]     at callPluginPrintFunction (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:20871:20)
[error]     at mainPrintInternal (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:20854:18)
[error]     at mainPrint (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:20837:14)
[error]     at AstPath.call (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:19316:14)
[error]     at printTopLevelParts (/home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-svelte/plugin.js:1515:33)
[error]     at Object.print (/home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-svelte/plugin.js:929:16)
[error]     at Object.print (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-tailwindcss/dist/index.mjs:2353:59544)
[error]     at callPluginPrintFunction (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:20871:20)
packages/site/src/routes/+layout.ts 11ms (unchanged)
packages/site/src/routes/+page.svelte{
    "type": "Script",
    "start": 0,
    "end": 283,
    "context": "default",
    "content": {
        "type": "Program",
        "start": 272,
        "end": 274,
        "loc": {
            "start": {
                "line": 1,
                "column": 0
            },
            "end": {
                "line": 1,
                "column": 274
            }
        },
        "body": [
            {
                "type": "BlockStatement",
                "start": 272,
                "end": 274,
                "loc": {
                    "start": {
                        "line": 1,
                        "column": 272
                    },
                    "end": {
                        "line": 1,
                        "column": 274
                    }
                },
                "body": []
            }
        ],
        "sourceType": "module"
    }
}

[error] packages/site/src/routes/+page.svelte: Error: unknown node type: Script
[error]     at Object.print (/home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-svelte/plugin.js:1474:11)
[error]     at Object.print (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-tailwindcss/dist/index.mjs:2353:59544)
[error]     at callPluginPrintFunction (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:20871:20)
[error]     at mainPrintInternal (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:20854:18)
[error]     at mainPrint (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:20837:14)
[error]     at AstPath.call (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:19316:14)
[error]     at printTopLevelParts (/home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-svelte/plugin.js:1515:33)
[error]     at Object.print (/home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-svelte/plugin.js:929:16)
[error]     at Object.print (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-tailwindcss/dist/index.mjs:2353:59544)
[error]     at callPluginPrintFunction (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:20871:20)
packages/site/src/routes/about/+page.svelte 14ms (unchanged)
packages/site/src/routes/posts/[id]/[[slug]]/+page.server.ts 77ms (unchanged)
packages/site/src/routes/posts/[id]/[[slug]]/+page.svelte{
    "type": "Script",
    "start": 0,
    "end": 279,
    "context": "default",
    "content": {
        "type": "Program",
        "start": 268,
        "end": 270,
        "loc": {
            "start": {
                "line": 1,
                "column": 0
            },
            "end": {
                "line": 1,
                "column": 270
            }
        },
        "body": [
            {
                "type": "BlockStatement",
                "start": 268,
                "end": 270,
                "loc": {
                    "start": {
                        "line": 1,
                        "column": 268
                    },
                    "end": {
                        "line": 1,
                        "column": 270
                    }
                },
                "body": []
            }
        ],
        "sourceType": "module"
    }
}

[error] packages/site/src/routes/posts/[id]/[[slug]]/+page.svelte: Error: unknown node type: Script
[error]     at Object.print (/home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-svelte/plugin.js:1474:11)
[error]     at Object.print (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-tailwindcss/dist/index.mjs:2353:59544)
[error]     at callPluginPrintFunction (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:20871:20)
[error]     at mainPrintInternal (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:20854:18)
[error]     at mainPrint (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:20837:14)
[error]     at AstPath.call (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:19316:14)
[error]     at printTopLevelParts (/home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-svelte/plugin.js:1515:33)
[error]     at Object.print (/home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-svelte/plugin.js:929:16)
[error]     at Object.print (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-tailwindcss/dist/index.mjs:2353:59544)
[error]     at callPluginPrintFunction (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:20871:20)
packages/site/src/routes/posts/+page.server.ts 24ms (unchanged)
packages/site/src/routes/posts/+page.svelte{
    "type": "Script",
    "start": 0,
    "end": 147,
    "context": "default",
    "content": {
        "type": "Program",
        "start": 136,
        "end": 138,
        "loc": {
            "start": {
                "line": 1,
                "column": 0
            },
            "end": {
                "line": 1,
                "column": 138
            }
        },
        "body": [
            {
                "type": "BlockStatement",
                "start": 136,
                "end": 138,
                "loc": {
                    "start": {
                        "line": 1,
                        "column": 136
                    },
                    "end": {
                        "line": 1,
                        "column": 138
                    }
                },
                "body": []
            }
        ],
        "sourceType": "module"
    }
}

[error] packages/site/src/routes/posts/+page.svelte: Error: unknown node type: Script
[error]     at Object.print (/home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-svelte/plugin.js:1474:11)
[error]     at Object.print (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-tailwindcss/dist/index.mjs:2353:59544)
[error]     at callPluginPrintFunction (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:20871:20)
[error]     at mainPrintInternal (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:20854:18)
[error]     at mainPrint (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:20837:14)
[error]     at AstPath.call (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:19316:14)
[error]     at printTopLevelParts (/home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-svelte/plugin.js:1515:33)
[error]     at Object.print (/home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-svelte/plugin.js:929:16)
[error]     at Object.print (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier-plugin-tailwindcss/dist/index.mjs:2353:59544)
[error]     at callPluginPrintFunction (file:///home/hrishikesh/projects/ntl-blog/node_modules/prettier/index.mjs:20871:20)
packages/site/src/tailwind.css 33ms (unchanged)
packages/site/svelte.config.js 13ms (unchanged)
packages/site/tailwind.config.ts 55ms (unchanged)
packages/site/tsconfig.json 3ms (unchanged)
packages/site/vite.config.ts 9ms (unchanged)
packages/utils/index.ts 16ms (unchanged)
packages/utils/package.json 2ms (unchanged)
packages/utils/tsconfig.json 2ms (unchanged)
prettier.config.js 6ms (unchanged)
turbo.json 4ms (unchanged)

I'm using Node.js 20 in Ubuntu 24.04 (WSL).

@Bewinxed
Copy link

Bewinxed commented Aug 6, 2024

Trying to add Prettier to my project: https://github.com/hrishikesh-k/blog. Running npx prettier . --write fails with the above error. Here's the entire output:

Terminal output
I'm using Node.js 20 in Ubuntu 24.04 (WSL).

Just had this issue, refer to the documentselectors setting in the readme and it works after.

this is a regression, however, and this is a workaround not a solution

@hrishikesh-k
Copy link
Author

I could be wrong, but documentselectors looks to be VSCode-spcific. Forgot to mention that I'm not using VSCode but WebStorm.

@Bewinxed
Copy link

Bewinxed commented Aug 6, 2024 via email

@Bewinxed
Copy link

Bewinxed commented Aug 6, 2024 via email

@hrishikesh-k
Copy link
Author

I tried downgrading to 3.0.3, but it's still broken for me.

@dummdidumm
Copy link
Member

This has something to do with prettier-plugin-tailwindcss, if I remove it, it works

@hrishikesh-k
Copy link
Author

Pretty sure it's coming from this plugin itself, at least in my case. I tried to comment out the Tailwind plugin stuff, but I continue to get the same issue.

@dyc3
Copy link

dyc3 commented Aug 29, 2024

I'm also encountering this issue. I'm working on adding support for svelte files to biome's playground: biomejs/website#1010.

I've tracked down where this is being thrown from:

throw new Error('unknown node type: ' + node.type);

@dummdidumm
Copy link
Member

Pretty sure it's coming from this plugin itself, at least in my case. I tried to comment out the Tailwind plugin stuff, but I continue to get the same issue.

@hrishikesh-k can you do a branch on your repo to show how you have commented it out and still get the error? Because I did also use your repo and the error went away after removing the tailwind plugin.

@hrishikesh-k
Copy link
Author

I've updated all the deps and pushed the changes to main. Feel free to explore.

With that being said, I'm likely moving off to biome instead of dealing with eslint + prettier. Svelte is not completely supported there yet, but that's bearable for now (the script gets correctly linted which is good enoug for me). So at this point, I'm no longer blocked by this issue.

@melMass
Copy link

melMass commented Oct 25, 2024

Same here out of the blue

prettier error
2024-10-25 18:48:26[ERROR] Formatter 'prettier' error: {
    "type": "Script",
    "start": 0,
    "end": 71,
    "context": "default",
    "content": {
        "type": "Program",
        "start": 60,
        "end": 62,
        "loc": {
            "start": {
                "line": 1,
                "column": 0
            },
            "end": {
                "line": 1,
                "column": 62
            }
        },
        "body": [
            {
                "type": "BlockStatement",
                "start": 60,
                "end": 62,
                "loc": {
                    "start": {
                        "line": 1,
                        "column": 60
                    },
                    "end": {
                        "line": 1,
                        "column": 62
                    }
                },
                "body": []
            }
        ],
        "sourceType": "module"
    }
}
[error] src/routes/ease/+page.svelte: Error: unknown node type: Script
[error]     at Object.print (/Users/melmassadian/dev/melmass/mtb/node_modules/prettier-plugin-svelte/plugin.js:1474:11)
[error]     at callPluginPrintFunction (/Users/melmassadian/dev/melmass/mtb/node_modules/prettier/index.js:8601:26)
[error]     at mainPrintInternal (/Users/melmassadian/dev/melmass/mtb/node_modules/prettier/index.js:8550:22)
[error]     at mainPrint (/Users/melmassadian/dev/melmass/mtb/node_modules/prettier/index.js:8537:18)
[error]     at AstPath.call (/Users/melmassadian/dev/melmass/mtb/node_modules/prettier/index.js:8359:24)
[error]     at printTopLevelParts (/Users/melmassadian/dev/melmass/mtb/node_modules/prettier-plugin-svelte/plugin.js:1515:33)
[error]     at Object.print (/Users/melmassadian/dev/melmass/mtb/node_modules/prettier-plugin-svelte/plugin.js:929:16)
[error]     at callPluginPrintFunction (/Users/melmassadian/dev/melmass/mtb/node_modules/prettier/index.js:8601:26)
[error]     at mainPrintInternal (/Users/melmassadian/dev/melmass/mtb/node_modules/prettier/index.js:8550:22)
[error]     at mainPrint (/Users/melmassadian/dev/melmass/mtb/node_modules/prettier/index.js:8537:18)

@melMass
Copy link

melMass commented Oct 31, 2024

Found the issue by checking the lockfile, I had a dep installing an old version of prettier (sveld and a farme plugin in my case). Removing them / purging submodules / re-installing the workspace worked

@tiagoporto
Copy link

I was facing the same issue.

Check if your prettier config has.

"embeddedLanguageFormatting": "off"

Enabling it fixed the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants