Home > Mobile >  npm ERR! invalid options argument
npm ERR! invalid options argument

Time:12-08

Software specifications

Software OS npm npx node
Version Windows 10 v8.1.2 v8.1.2 v16.13.1

I was following this video and when I try to create a react application on my system by using the following command

npx create-react-app demo

It shows the following error:

npm ERR! invalid options argument

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\hp\AppData\Local\npm-cache\_logs\2021-12-07T16_44_17_434Z-debug.log

Log file's content

0 verbose cli [
0 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
0 verbose cli   'C:\\Users\\hp\\AppData\\Roaming\\nvm\\v11.0.0\\node_modules\\npm\\bin\\npm-cli.js',
0 verbose cli   'exec',
0 verbose cli   '--',
0 verbose cli   'create-react-app',
0 verbose cli   'demo'
0 verbose cli ]
1 info using npm@8.1.2
2 info using node@v16.13.1
3 timing npm:load:whichnode Completed in 1ms
4 timing config:load:defaults Completed in 1ms
5 timing config:load:file:C:\Users\hp\AppData\Roaming\nvm\v11.0.0\node_modules\npm\npmrc Completed in 2ms
6 timing config:load:builtin Completed in 3ms
7 timing config:load:cli Completed in 2ms
8 timing config:load:env Completed in 1ms
9 timing config:load:file:C:\Users\hp\OneDrive\Desktop\.npmrc Completed in 1ms
10 timing config:load:project Completed in 2ms
11 timing config:load:file:C:\Users\hp\.npmrc Completed in 1ms
12 timing config:load:user Completed in 1ms
13 timing config:load:file:C:\Users\hp\AppData\Roaming\npm\etc\npmrc Completed in 0ms
14 timing config:load:global Completed in 0ms
15 timing config:load:validate Completed in 1ms
16 timing config:load:credentials Completed in 1ms
17 timing config:load:setEnvs Completed in 1ms
18 timing config:load Completed in 13ms
19 timing npm:load:configload Completed in 13ms
20 timing npm:load:setTitle Completed in 0ms
21 timing npm:load:setupLog Completed in 1ms
22 timing config:load:flatten Completed in 4ms
23 timing npm:load:cleanupLog Completed in 2ms
24 timing npm:load:configScope Completed in 0ms
25 timing npm:load:projectScope Completed in 1ms
26 timing npm:load Completed in 22ms
27 verbose stack TypeError: invalid options argument
27 verbose stack     at optsArg (C:\Users\hp\AppData\Roaming\nvm\v11.0.0\node_modules\npm\node_modules\mkdirp\lib\opts-arg.js:13:11)
27 verbose stack     at mkdirp (C:\Users\hp\AppData\Roaming\nvm\v11.0.0\node_modules\npm\node_modules\mkdirp\index.js:11:10)
27 verbose stack     at tryCatcher (C:\Users\hp\AppData\Roaming\nvm\v11.0.0\node_modules\npm\node_modules\bluebird\js\release\util.js:16:23)
27 verbose stack     at ret (eval at makeNodePromisifiedEval (C:\Users\hp\AppData\Roaming\nvm\v11.0.0\node_modules\npm\node_modules\bluebird\js\release\promisify.js:184:12), <anonymous>:13:39)
27 verbose stack     at Object.mkdirfix (C:\Users\hp\AppData\Roaming\nvm\v11.0.0\node_modules\npm\node_modules\npm-registry-fetch\node_modules\cacache\lib\util\fix-owner.js:36:10)
27 verbose stack     at makeTmp (C:\Users\hp\AppData\Roaming\nvm\v11.0.0\node_modules\npm\node_modules\npm-registry-fetch\node_modules\cacache\lib\content\write.js:121:19)
27 verbose stack     at write (C:\Users\hp\AppData\Roaming\nvm\v11.0.0\node_modules\npm\node_modules\npm-registry-fetch\node_modules\cacache\lib\content\write.js:35:19)
27 verbose stack     at putData (C:\Users\hp\AppData\Roaming\nvm\v11.0.0\node_modules\npm\node_modules\npm-registry-fetch\node_modules\cacache\put.js:11:10)
27 verbose stack     at Object.x.put (C:\Users\hp\AppData\Roaming\nvm\v11.0.0\node_modules\npm\node_modules\npm-registry-fetch\node_modules\cacache\locales\en.js:28:37)
27 verbose stack     at WriteStream._flush (C:\Users\hp\AppData\Roaming\nvm\v11.0.0\node_modules\npm\node_modules\npm-registry-fetch\node_modules\make-fetch-happen\cache.js:156:21)
27 verbose stack     at WriteStream._write (C:\Users\hp\AppData\Roaming\nvm\v11.0.0\node_modules\npm\node_modules\flush-write-stream\index.js:36:35)
27 verbose stack     at doWrite (C:\Users\hp\AppData\Roaming\nvm\v11.0.0\node_modules\npm\node_modules\readable-stream\lib\_stream_writable.js:409:139)
27 verbose stack     at writeOrBuffer (C:\Users\hp\AppData\Roaming\nvm\v11.0.0\node_modules\npm\node_modules\readable-stream\lib\_stream_writable.js:398:5)
27 verbose stack     at WriteStream.Writable.write (C:\Users\hp\AppData\Roaming\nvm\v11.0.0\node_modules\npm\node_modules\readable-stream\lib\_stream_writable.js:307:11)
27 verbose stack     at WriteStream.end (C:\Users\hp\AppData\Roaming\nvm\v11.0.0\node_modules\npm\node_modules\flush-write-stream\index.js:45:41)
27 verbose stack     at WriteStream.end (C:\Users\hp\AppData\Roaming\nvm\v11.0.0\node_modules\npm\node_modules\flush-write-stream\index.js:42:47)
28 verbose cwd C:\Users\hp\OneDrive\Desktop
29 verbose Windows_NT 10.0.18363
30 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\hp\\AppData\\Roaming\\nvm\\v11.0.0\\node_modules\\npm\\bin\\npm-cli.js" "exec" "--" "create-react-app" "demo"
31 verbose node v16.13.1
32 verbose npm  v8.1.2
33 error invalid options argument
34 verbose exit 1

Also tried running

npm i create-react-app -g demo

This resulted in the same error as above

Tried Cloning and Running

I also tried to clone an already working react application, and when I ran the following command to install dependencies

npm i

This gave the following error:

npm ERR! invalid options argument

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\hp\AppData\Local\npm-cache\_logs\2021-12-07T17_12_17_513Z-debug.log

When trying to clear the cache using npm cache clean --force the following error occurs:

npm WARN using --force Recommended protections disabled.

Can someone help me understand what went wrong? Have I not done some installation correctly or missed out on any installation step? What can I do to get started with creating a react application on my machine? Any kind of help is appreciated. If you need any more information please let me know in the comments. Thanks!

CodePudding user response:

The problem seems to be that of an inappropriate installation. The go to way to fix this would be to ensure a proper uninstall of node and npm. Please follow the steps mentioned here. Once properly uninstalled, head over to install node and proceed with the re-installation.

  • Related