Nuxt build on production failed: SyntaxError: Invalid or unexpected token

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

Nuxt build on production failed: SyntaxError: Invalid or unexpected token

问题

我为此烦恼,我已经搜了好几个小时,尝试了各种方法,从降级 nuxt 到回溯我的旧提交,看看发生了什么变化。

我在 AWS codebuild 上收到以下构建错误:

> nuxt build
--
165 |  
166 | /application/dotoo-web/node_modules/@nuxt/utils/node_modules/consola/dist/shared/consola.4bbae468.cjs:473
167 | if (codePoint >= 0x3_00 && codePoint <= 0x3_6F) {
168 | ^^^
169 |  
170 | SyntaxError: Invalid or unexpected token
171 | at Module._compile (internal/modules/cjs/loader.js:723:23)
172 | at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
173 | at Module.load (internal/modules/cjs/loader.js:653:32)
174 | at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
175 | at Function.Module._load (internal/modules/cjs/loader.js:585:3)
176 | at Module.require (internal/modules/cjs/loader.js:692:17)
177 | at require (internal/modules/cjs/helpers.js:25:18)
178 | at Object.<anonymous> (/application/dotoo-web/node_modules/@nuxt/utils/node_modules/consola/dist/index.cjs:5:15)
179 | at Module._compile (internal/modules/cjs/loader.js:778:30)
180 | at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
181 | npm ERR! code ELIFECYCLE
182 | npm ERR! errno 1
183 | npm ERR! dotoo-web@2.36.0 build: `nuxt build`
184 | npm ERR! Exit status 1

我使用的是 Nuxt 2.17.0,正在推送到由第三方为我们构建的 AWS codebuild 管道。根据构建日志中的这行,它似乎仍在使用 Node 10:Status: Downloaded newer image for node:10-alpine

有人有线索吗?

英文:

Im breaking my head over this, i've been searching for hours and trying everything, from downgrading nuxt to tracking back in my older commits to see what changed.

I get the following build error on AWS codebuild:

> nuxt build
--
165 |  
166 | /application/dotoo-web/node_modules/@nuxt/utils/node_modules/consola/dist/shared/consola.4bbae468.cjs:473
167 | if (codePoint >= 0x3_00 && codePoint <= 0x3_6F) {
168 | ^^^
169 |  
170 | SyntaxError: Invalid or unexpected token
171 | at Module._compile (internal/modules/cjs/loader.js:723:23)
172 | at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
173 | at Module.load (internal/modules/cjs/loader.js:653:32)
174 | at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
175 | at Function.Module._load (internal/modules/cjs/loader.js:585:3)
176 | at Module.require (internal/modules/cjs/loader.js:692:17)
177 | at require (internal/modules/cjs/helpers.js:25:18)
178 | at Object.<anonymous> (/application/dotoo-web/node_modules/@nuxt/utils/node_modules/consola/dist/index.cjs:5:15)
179 | at Module._compile (internal/modules/cjs/loader.js:778:30)
180 | at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
181 | npm ERR! code ELIFECYCLE
182 | npm ERR! errno 1
183 | npm ERR! dotoo-web@2.36.0 build: `nuxt build`
184 | npm ERR! Exit status 1

Im using Nuxt 2.17.0 and i'm pushing to a aws codebuild pipeline that was build by a third party for us. It seems it's still on Node 10 according to this line in the build log: Status: Downloaded newer image for node:10-alpine

Does anybody have a clue?

答案1

得分: 3

错误消息指的是在Node.js中使用数字分隔符,在Node版本低于12.8.1时不受支持。

167 | if (codePoint >= 0x3_00 && codePoint <= 0x3_6F) {

这里的0x3_00使用了数字分隔符_。如果没有它,表示法会像0x300那样。

请查看 https://node.green/#ES2021-features--numeric-separators 获取支持此功能的Node.js版本列表。

所以看起来你需要将 node:10-alpine 升级至至少 node:12-alpine 或者最好是如果12不起作用的话选择 node:14-alpine

英文:

The error message refers to the use of a numeric separator in Node.js, which is not supported in Node versions prior to 12.8.1.

167 | if (codePoint &gt;= 0x3_00 &amp;&amp; codePoint &lt;= 0x3_6F) {

0x3_00 here uses a numeric separator _. Without it, the notation would look like 0x300.

See https://node.green/#ES2021-features--numeric-separators for the list of Node.js versions that support this feature.

So looks like you need to upgrade node:10-alpine to at least node:12-alpine or better node:14-alpine if 12th doesn't work.

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

发表评论

匿名网友

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

确定