通过 npm 卸载 quasar-cli 不起作用?

Uninstalling quasar-cli via npm not working?

我在我的 windows 机器上做一个 Quasar 项目,突然它说 quasar is not recognized as an internal or external command. 我尝试使用命令 npm uninstall -g quasar-cli 卸载 quasar-cli,但它似乎不起作用。 npm list -g --depth=0 命令告诉我,我还有 quasar-cli。

C:\Users\nitin>npm uninstall -g quasar-cli
up to date in 0.028s
C:\Users\nitin>npm list -g --depth=0
C:\Users\nitin\AppData\Roaming\npm
+-- @quasar/cli@1.1.0
+-- cordova@9.0.0
+-- nodemon@2.0.4
`-- vue-cli@2.9.6

我也无法再次安装它,因为它给出了以下错误

C:\Users\nitin>npm install -g quasar-cli
npm WARN deprecated @babel/preset-stage-2@7.0.0-beta.54: � We've deprecated any official stage presets in favor of users explicitly opt-ing into the proposals they want to use versus any perceived convenience. You can also check https://github.com/babel/babel/issues/7770 for more information.
npm WARN deprecated chokidar@2.0.4: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated @babel/preset-stage-3@7.0.0-beta.54: � We've deprecated any official stage presets in favor of users explicitly opt-ing into the proposals they want to use versus any perceived convenience. You can also check https://github.com/babel/babel/issues/7770 for more information.
npm WARN deprecated core-js@2.6.11: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
npm WARN deprecated fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated joi@11.4.0: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated topo@2.0.2: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated hoek@4.2.1: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN rollback Rolling back is-descriptor@1.0.2 failed (this is probably harmless): EPERM: operation not permitted, lstat 'C:\Users\nitin\AppData\Roaming\npm\node_modules\quasar-cli\node_modules\define-property\node_modules'
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.2 (node_modules\quasar-cli\node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN notsup Unsupported engine for watchpack-chokidar2@2.0.0: wanted: {"node":"<8.10.0"} (current: {"node":"12.17.0","npm":"6.14.4"})
npm WARN notsup Not compatible with your version of node/npm: watchpack-chokidar2@2.0.0
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules\quasar-cli\node_modules\watchpack\node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN ajv-keywords@3.5.1 requires a peer of ajv@^6.9.1 but none is installed. You must install peer dependencies yourself.

npm ERR! code EEXIST
npm ERR! path C:\Users\nitin\AppData\Roaming\npm\node_modules\quasar-cli\bin\quasar
npm ERR! dest C:\Users\nitin\AppData\Roaming\npm\quasar
npm ERR! EEXIST: file already exists, cmd shim 'C:\Users\nitin\AppData\Roaming\npm\node_modules\quasar-cli\bin\quasar' -> 'C:\Users\nitin\AppData\Roaming\npm\quasar'
npm ERR! File exists: C:\Users\nitin\AppData\Roaming\npm\quasar
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\nitin\AppData\Roaming\npm-cache\_logs20-07-19T04_24_31_029Z-debug.log

你能告诉我哪里错了吗?我是 npm 和 JS 的新手,所以如果我遗漏了什么请更正。

我最近对遇到的类似问题执行了手动删除,而是选择使用 rimraf 包从安装全局包的 npm 根目录中删除模块。

安装 rimraf 使用:

npm install rimraf -g

导航到安装全局包的根文件夹。可以使用以下方法找到此路径:

npm root -g

CD 进入根文件夹后,使用以下命令对 quasar-cli 模块执行删除:

rimraf <name of folder>

注意: <name of folder> 是 quasar-cli 所在文件夹的名称。执行 dir/w 列出目录中的文件夹,以检查要在上面的命令中插入的文件夹的确切名称。

rimraf 包是跨平台的,等同于我在 bash 终端 rm -rf 中使用的递归删除文件和文件夹的包。您可以通过以下方式在 windows 上看到这一点:https://www.youtube.com/watch?v=qPCK6mWeqsk

检查是否按照您之前的命令删除了软件包:

npm list -g --depth=0

希望对您有所帮助

我最终不得不从

中删除node-modules文件夹
C:\Users\{user}\AppData\Roaming\npm\node_modules

因为我不仅对 quasar 有疑问,对 vue 和其他一切也有疑问。 vue --version 也没有用。

我从上面的路径和我的项目文件夹中删除了 node-modules 文件夹,然后使用 npm install -g 命令重新安装它们。此命令需要 运行 在您的 package.json 文件所在的项目文件夹中。

否则您可以单独安装(全局使用附加到命令的 -g)您需要的每个组件。 安装软件包后重新启动命令提示符。 不要忘记保留您使用的所有软件包的列表

npm list -g --depth=0`