ERROR FIXED -  a syntax error related to the use of the "nullish" coalescing assignment operator (??=),

ERROR FIXED - a syntax error related to the use of the "nullish" coalescing assignment operator (??=),

While trying to create a new React application using

npx create-react-app        

I encountered this error below:

ERROR:
/home/geekelo/.nvm/versions/node/v14.16.0/lib/node_modules/npm/node_modules/@npmcli/agent/lib/agents.js:105
    options.lookup ??= this.#options.lookup
                   ^^^

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> (/home/geekelo/.nvm/versions/node/v14.16.0/lib/node_modules/npm/node_modules/@npmcli/agent/lib/index.js:7:15)

        


It is a syntax error related to the use of the "nullish" coalescing assignment operator (??=), which is a feature introduced in Node.js version 15.0.0. The error message indicates that the current version of Node.js (v14.16.0) does not support this syntax. So I figured out that installing the node's latest version should be a good solution.

Then, I ran;

nvm install node        

It installed Node v 22. After that, I could create my React app without further errors. I hope it works for everyone else encountering the same error.


Please comment on your preferred method or other effective ways of solving this kind of error below. Thank you




I'm a React Developer who loves to code. Need an extra team member? I'd be happy to work and collaborate with you.

Email: [email protected]

Github: github.com/geekelo

Website: geekelo.com.ng


要查看或添加评论,请登录

Eloghene Otiede的更多文章

社区洞察

其他会员也浏览了