nuxt 失败并出现无法解析源以进行导入分析的错误

nuxt fails with an error not being able to parse source for import analysis

当我尝试创建服务器时,它抛出 500 错误并在终端中显示以下错误:

[SSR] Error transforming  virtual:C:/Users/User/Documents/CODING/Ted's/.nuxt/plugins/server.mjs: Failed to parse source for import analysis because the content contains invalid JS syntax. If you are using JSX, make sure to name the file with the .jsx or .tsx extension.

我已经尝试 运行 npm cache clean --force 我已经重新安装了 npm 很多次,因为每个人都拥有它所在目录的完整权限,运行 VSCode 作为管理员,我没有想法。

问题很可能与这些问题有关:

This PR addresses issues when using rollup for a project with ' in the path, for example /Users/Daniel's Projects/project/. Although normal imports are escaped correctly, it seems that dynamic imports are treated differently and we need to escape them as well.

您的路径 C:/Users/User/Documents/CODING/Ted's/ 包含一个 ',根据问题,这会导致该问题。

所以问题的解决方案是摆脱你路径中的那个 ',或者等到 nuxt 版本发布来解决这个问题。

given Everyone full privs for the dir it is in, ran VSCode as admin, I'm out of ideas.

这是你永远不应该做的事情。只有极少数情况下您可能需要它,即使那样您也应该多次重新考虑。 运行 VSCode 作为管理员会允许 vscode 及其所有已安装的插件扰乱大量系统。如果你这样做,你需要完全信任所有这些。