创建React App语法错误:意外令牌

编程入门 行业动态 更新时间:2024-10-10 07:21:33

创建React App语法错误:意外<a href=https://www.elefans.com/category/jswz/34/1771317.html style=令牌"/>

创建React App语法错误:意外令牌

我正在学习一个教程,但我无法启动create-react-app,因为它不断遇到此语法错误。我正在使用节点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(使用...styles标志运行时为8.0.0)以来,已支持对象文字中的扩展语法(如--harmony中所使用。)。]

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

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

更多推荐

创建React App语法错误:意外令牌

本文发布于:2024-05-13 10:02:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1759410.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:令牌   意外   语法错误   React   App

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!