如何正确彻底删除webpack 全局或是局部?

  • 回答 (1)
  • 关注 (0)
  • 查看 (230)

这个那问题很重要如何安全的安装webpack ,卸载webpack。主要是为了防止玩webpack玩坏了还可以从西再来,请老司机带个路 晚上回去要可能要从做系统了😄

刚入门

看着文档全局安装webpack4.x,

npm install --global webpack 

顺带也安装了webpack-cli

npm install --save-dev webpack-cli

检查版本

webpack -v

输出内容是 4.10.2

当时感觉非常nice

-------------------------------------------------

问题是我又考虑练手问题 直接

rm -rf  node_modules package-lock.json

现在问题来了 我继续安装了webpack

lifedeMBP:Documents life$ webpack
-bash: /Users/life/.nvm/versions/node/v10.3.0/bin/webpack: No such file or directory
lifedeMBP:Documents life$ npm install --global webpack
/Users/life/.nvm/versions/node/v10.3.0/bin/webpack -> /Users/life/.nvm/versions/node/v10.3.0/lib/node_modules/webpack/bin/webpack.js

> fsevents@1.2.4 install /Users/life/.nvm/versions/node/v10.3.0/lib/node_modules/webpack/node_modules/fsevents
> node install

[fsevents] Success: "/Users/life/.nvm/versions/node/v10.3.0/lib/node_modules/webpack/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64/fse.node" already installed
Pass --update-binary to reinstall or --build-from-source to recompile
+ webpack@4.11.0
added 387 packages from 296 contributors in 71.214s
lifedeMBP:Documents life$ webpack
One CLI for webpack must be installed. These are recommended choices, delivered as separate packages:
 - webpack-cli (https://github.com/webpack/webpack-cli)
   The original webpack full-featured CLI.
 - webpack-command (https://github.com/webpack-contrib/webpack-command)
   A lightweight, opinionated webpack CLI.
We will use "npm" to install the CLI via "npm install -D".
Which one do you like to install (webpack-cli/webpack-command):
webpack-cli
Installing 'webpack-cli' (running 'npm install -D webpack-cli')...
npm WARN saveError ENOENT: no such file or directory, open '/Users/life/Documents/package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open '/Users/life/Documents/package.json'
npm WARN webpack-cli@3.0.2 requires a peer of webpack@^4.x.x but none is installed. You must install peer dependencies yourself.
npm WARN Documents No description
npm WARN Documents No repository field.
npm WARN Documents No README data
npm WARN Documents No license field.

+ webpack-cli@3.0.2
added 105 packages from 44 contributors and audited 143 packages in 25.231s
found 0 vulnerabilities

{ Error: Cannot find module 'webpack-cli'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:594:15)
    at Function.Module._load (internal/modules/cjs/loader.js:520:25)
    at Module.require (internal/modules/cjs/loader.js:650:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at runCommand.then (/Users/life/.nvm/versions/node/v10.3.0/lib/node_modules/webpack/bin/webpack.js:149:5)
    at process._tickCallback (internal/process/next_tick.js:68:7) code: 'MODULE_NOT_FOUND' }
lifedeMBP:Documents life$ 

开个玩笑(我在想我是不是要给mac从新做个系统)

用心用心提问于
用心邀请了闰土大叔来回答
闰土大叔我是一枚活跃于前端圈的90后大叔,平时爱分享点互联网码农的职场经验。回答于

谢邀。

首先,我目前暂无对这个问题的解决办法,只能提供点思路给你。

rm -rf * 删除当前目录下的所有文件,这个命令很危险,应避免使用。
所删除的文件,一般都不能恢复!

还有这篇关于webpack cli的文章可能会帮助到你:https://segmentfault.com/a/1190000013699050

还有就是关于package-lock.json的作用:package-lock.json是当 node_modules 或 package.json 发生变化时自动生成的文件。这个文件主要功能是确定当前安装的包的依赖,以便后续重新安装的时候生成相同的依赖,而忽略项目开发过程中有些依赖已经发生的更新。

因为我也没遇到过你说的这个问题,所以抱歉了,老铁。

扫码关注云+社区

领取腾讯云代金券