Reputation: 211
I am trying to create a new React app using this command on Windows using Node 16.14
npx create-react-app my-app
But it fails with this error npm ERR! Unexpected token '.'
From the log, this is the stack trace:
28 verbose stack C:\ProgramData\nvm\v16.14.0\node_modules\npm\node_modules\libnpmexec:1
28 verbose stack ../workspaces/libnpmexec
28 verbose stack ^
28 verbose stack
28 verbose stack SyntaxError: Unexpected token '.'
28 verbose stack at Object.compileFunction (node:vm:352:18)
28 verbose stack at wrapSafe (node:internal/modules/cjs/loader:1032:15)
28 verbose stack at Module._compile (node:internal/modules/cjs/loader:1067:27)
28 verbose stack at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
28 verbose stack at Module.load (node:internal/modules/cjs/loader:981:32)
28 verbose stack at Function.Module._load (node:internal/modules/cjs/loader:822:12)
28 verbose stack at Module.require (node:internal/modules/cjs/loader:1005:19)
28 verbose stack at require (node:internal/modules/cjs/helpers:102:18)
28 verbose stack at Object.<anonymous> (C:\ProgramData\nvm\v16.14.0\node_modules\npm\lib\commands\exec.js:1:17)
28 verbose stack at Module._compile (node:internal/modules/cjs/loader:1103:14)
Can you please tell me what is the issue?
Upvotes: 4
Views: 7233
Reputation: 1
run the following commands:
nvm install --lts (installs the latest LTS version)
then
nvm install node (installs the latest available version)
then
nvm node (to use the latest version)
then
node -v
(to see the version / confirm you have the latest version)
Upvotes: 0
Reputation: 1
The error is in the debuglog.js file, line 10, located in the path:
C:\Program Files\nodejs\node_modules\npm\node_modules\debuglog\debuglog.js:10
The error is quite simple, to fix it change the command that is there as follows if (!debugs[set�)
to if (!debugs[set])
and save as administrator.
Upvotes: 0
Reputation: 5322
If you're using nvm, upgrading to the latest version of nvm (1.1.9 at the time of writing), uninstalling the node version and reinstalling it fixes the issue.
They issued a special patch for that issue
Upvotes: 6
Reputation: 126
Try to downgrade npm version. I had this same, on 16.14.0. I recommend nvm for changing node version. For example: nvm install 14.18.1 nvm use 14.18.1
Upvotes: 4