gpt4 book ai didi

javascript - 创建 React App 语法错误 : Unexpected Token

转载 作者:行者123 更新时间:2023-12-05 05:02:38 25 4
gpt4 key购买 nike

我正在学习教程,但我无法启动 create-react-app,因为它一直遇到此语法错误。我正在使用 Node v8.1.4 和 npm v6.14.5。以下是我的代码。不确定错误是什么。

yeryndo@Yeryn:/mnt/c/Users/yeryn/desktop/Exercise Files/ch02/02_02/start$ create-react-app react-is-fun
/usr/local/lib/node_modules/create-react-app/node_modules/chalk/source/index.js:103
...styles,
^^^

SyntaxError: Unexpected token ...
at createScript (vm.js:74:10)
at Object.runInThisContext (vm.js:116:10)
at Module._compile (module.js:533:28)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/usr/local/lib/node_modules/create-react-app/createReactApp.js:37:15)

最佳答案

问题是由this function call引起的在 chalk 库中:

const proto = Object.defineProperties(() => {}, {
...styles,
level: {
// omitted
}
}

根据 MDN ,自 Node.js 8.3.0(8.0.0 使用 --harmony 运行时)开始支持在对象文字中传播语法(如 ...styles标志)。

由于您使用的是 8.1.4 版,您有两个基本选择:

  1. 升级 Node.js
  2. 使用 --harmony flag 运行 Node.js

关于javascript - 创建 React App 语法错误 : Unexpected Token,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62078060/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com