Workshop project - SyntaxError: Unexpected token '?='

Hello, this is my first time using Redwood. I’m actually following Amy Dutton’s workshop from React Summit and I keep running into this error after I open the project in VSCode. All commands (yarn rw storybook) stop working afterwards and I get the error below:

cwd ??= process.env.RWJS_CWD;

SyntaxError: Unexpected token '??='
    at wrapSafe (internal/modules/cjs/loader.js:979:16)
    at Module._compile (internal/modules/cjs/loader.js:1027:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/Users/janbe30/Coding/Playground/RedwoodJS/redwood-workshop/node_modules/@redwoodjs/core/dist/bins/redwood.js:30:1)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10

Any ideas how to fix? This is becoming quite the roadblock in learning RedwoodJS!

Hi @janbe30

Could you confirm what node version you are using to run your RedwoodJS project?

That operator is only available in certain Node versions starting around Node v15

You can find out with yarn rw info

yarn rw info

    OS: macOS 13.5.2
    Shell: 5.9 - /bin/zsh
    ---->>>>>> Node: 18.17.0 - /private/var/folders/ft/8320mthj6gbdd2pmc42x13480000gn/T/xfs-d57d3685/node
    Yarn: 3.7.0 - /private/var/folders/ft/8320mthj6gbdd2pmc42x13480000gn/T/xfs-d57d3685/yarn
    SQLite: 3.39.5 - /usr/bin/sqlite3
    Chrome: 120.0.6099.71
    Safari: 16.6
    @redwoodjs/core: 6.5.1 => 6.5.1 

Ohh that’s it! I had installed Node 20 but for some reason it keeps reverting back to 14 randomly. TY!

1 Like

Ah, that would do it. Glad it is working.

I think many people use nvm GitHub - nvm-sh/nvm: Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions to manage (or Volta).

Each project will have a .nvmrc to set the node version … currently at v18 for compatibility between Netlify and Prisma, but usually is lts.