3

I am following a tutorial and I cannot get create-react-app to start because it keeps running into this syntax error. I am using node v8.1.4 and npm v6.14.5. The following is my code. Not sure what the error is.

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)
0

1 Answer 1

2

The problem is caused by this function call in the chalk library:

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

According to MDN, spread syntax in object literals (as used in ...styles) has been supported since Node.js 8.3.0 (8.0.0 when running with the --harmony flag).

Since you're using version 8.1.4, you have two basic options:

  1. Upgrade Node.js
  2. Run Node.js with the --harmony flag
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you! It worked. Did not realize it was due to an older version
Im getting a similar error but have the latest node installed

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.