Something in my build process is introducing a syntax error, regarding globalThis.process.env.NODE_ENV

huangapple go评论55阅读模式
英文:

Something in my build process is introducing a syntax error, regarding globalThis.process.env.NODE_ENV

问题

使用Quasar,并且重新开始一个我一两周没碰的项目,我无法使其正常编译。当我像往常一样执行“quasar dev”时,网站无法构建:

[Quasar] boot error: SyntaxError: Unexpected string (at chunk-S3UJV3FY.js?v=56d0515d:1070:51)

有问题的行如下:

var instanceOf = globalThis.process && globalThis."development" === "production" ? function ...

我追踪到这行代码是jsutils的instanceOf部分,由graphql使用。原始行如下:

const instanceOf = globalThis.process && globalThis.process.env.NODE_ENV === 'production' ? function ...

因此,我立即可以看到构建过程的某些部分已更改,并且process.env.NODE_ENV被盲目替换为"development",但我无法弄清楚原因。

在git历史中没有与本地开发过程相关的内容,我已尝试清除node_modules和quasar的构建缓存。我之前一直在使用unplugin-auto-import,但我已卸载它,问题仍然存在。

英文:

So, using Quasar, and picking up a project I haven't messed with in a week or two, I cannot get it to compile properly. When I execute "quasar dev" as per usual, the site fails to build:

[Quasar] boot error: SyntaxError: Unexpected string (at chunk-S3UJV3FY.js?v=56d0515d:1070:51)

The offending line renders as:

var instanceOf = globalThis.process && globalThis."development" === "production" ? function ...

I traced this line to the instanceOf part of jsutils, as used by graphql. The original line is:

const instanceOf = globalThis.process && globalThis.process.env.NODE_ENV === 'production' ? function ...

So, right away, I can see that some part of the build process has changed, and process.env.NODE_ENV is being blindly replaced by "development", but I cannot figure out why.

There's nothing in the git history related to the local dev process, and I've tried clearing out node_modules, and the quasar build cache. I had been messing with unplugin-auto-import, but i've uninstalled it, and the problem persists.

答案1

得分: 1

这似乎是 GraphQL 中的某个 bug:

https://github.com/quasarframework/quasar/issues/16060

https://github.com/graphql/graphql-js/issues/3919

我通过修复 GraphQL 的版本来解决了它:

"graphql": "16.6.0",

vs

"graphql": "^16.6.0",

英文:

It looks like a bug somewhere in graphql:

https://github.com/quasarframework/quasar/issues/16060

https://github.com/graphql/graphql-js/issues/3919

I solved it by fixing graphql's verison:

> "graphql": "16.6.0",

vs

> "graphql": "^16.6.0",

答案2

得分: 0

升级到 Vite 版本 4 解决了我的问题。

英文:

Upgrading to vite version 4 solved my issue

huangapple
  • 本文由 发表于 2023年7月6日 21:35:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/76629422.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定