错误!无效的选项参数
npm ERR! invalid options argument
软件规格
Software
OS
npm
npx
node
Version
Windows 10
v8.1.2
v8.1.2
v16.13.1
我正在关注 this video,当我尝试使用以下命令在我的系统上创建一个 React 应用程序时
npx create-react-app demo
显示以下错误:
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\_logs21-12-07T16_44_17_434Z-debug.log
日志文件的内容
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
也尝试过运行
npm i create-react-app -g demo
这导致了与上面相同的错误
尝试克隆和 运行
我还尝试克隆一个已经工作的 React 应用程序,当我 运行 使用以下命令安装依赖项时
npm i
这给出了以下错误:
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\_logs21-12-07T17_12_17_513Z-debug.log
尝试使用 npm cache clean --force
清除缓存时出现以下错误:
npm WARN using --force Recommended protections disabled.
有人可以帮助我了解哪里出了问题吗?我是否没有正确完成某些安装或错过了任何安装步骤?我该怎么做才能开始在我的机器上创建 React 应用程序?任何形式的帮助表示赞赏。如果您需要更多信息,请在评论中告诉我。谢谢!
问题似乎是安装不当造成的。解决此问题的方法是确保正确卸载 node
和 npm
。请按照 here 中提到的步骤进行操作。
正确卸载后,前往 install node 并继续重新安装。
我也遇到过类似的问题,但是使用的是arch linux操作系统,这个跟你安装的好不好没有太大关系,有时候一些模块会互相干扰,因为兼容性问题。
在我跟踪错误的情况下,错误在 /usr/lib/node_modules/npm/node_modules/* 中。虽然我卸载重装了nodejs和npm也没有解决,所以我决定在卸载node后彻底删除node_modules文件夹,然后重新安装。
在您使用 Windows 的情况下,错误会将您发送到文件夹 C:\UsersAppData\Roaming\nvm*。所以我建议你卸载nodejs并完全删除nvm文件夹,因为它是导致错误的原因。
软件规格
Software | OS | npm | npx | node |
---|---|---|---|---|
Version | Windows 10 | v8.1.2 | v8.1.2 | v16.13.1 |
我正在关注 this video,当我尝试使用以下命令在我的系统上创建一个 React 应用程序时
npx create-react-app demo
显示以下错误:
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\_logs21-12-07T16_44_17_434Z-debug.log
日志文件的内容
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
也尝试过运行
npm i create-react-app -g demo
这导致了与上面相同的错误
尝试克隆和 运行
我还尝试克隆一个已经工作的 React 应用程序,当我 运行 使用以下命令安装依赖项时
npm i
这给出了以下错误:
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\_logs21-12-07T17_12_17_513Z-debug.log
尝试使用 npm cache clean --force
清除缓存时出现以下错误:
npm WARN using --force Recommended protections disabled.
有人可以帮助我了解哪里出了问题吗?我是否没有正确完成某些安装或错过了任何安装步骤?我该怎么做才能开始在我的机器上创建 React 应用程序?任何形式的帮助表示赞赏。如果您需要更多信息,请在评论中告诉我。谢谢!
问题似乎是安装不当造成的。解决此问题的方法是确保正确卸载 node
和 npm
。请按照 here 中提到的步骤进行操作。
正确卸载后,前往 install node 并继续重新安装。
我也遇到过类似的问题,但是使用的是arch linux操作系统,这个跟你安装的好不好没有太大关系,有时候一些模块会互相干扰,因为兼容性问题。 在我跟踪错误的情况下,错误在 /usr/lib/node_modules/npm/node_modules/* 中。虽然我卸载重装了nodejs和npm也没有解决,所以我决定在卸载node后彻底删除node_modules文件夹,然后重新安装。 在您使用 Windows 的情况下,错误会将您发送到文件夹 C:\UsersAppData\Roaming\nvm*。所以我建议你卸载nodejs并完全删除nvm文件夹,因为它是导致错误的原因。