linux下安装webpack遇到的问题
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux下安装webpack遇到的问题相关的知识,希望对你有一定的参考价值。
参考技术A Error: Cannot find module 'webpack-cli'at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at runCommand.then (/root/.nvm/versions/node/v10.15.0/lib/node_modules/webpack/bin/webpack.js:142:5)
at process._tickCallback (internal/process/next_tick.js:68:7) code: 'MODULE_NOT_FOUND'
[root@localhost webpack]# npm i webpack -g
很顺利就安装好了webpack
[root@localhost webpack]# webpack -h
但是就当我查看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.
We will use "npm" to install the CLI via "npm install -D".
Do you want to install 'webpack-cli' (yes/no):
我没有多思考就yes
然后就报出了最上面的错误
后来发现我现在的路径是[root@localhost webpack]# 但是我是 -g全局安装的webpack
但是当我输入yes的时候,系统查找的是我当前路径下的package.json当然了就无法安装了毕竟 webpack安装在全局,webpack-cli也得全局安装
[root@localhost webpack]# npm i webpack-cli -g
当然我就想看一下我之前全局安装过的npm 包都有哪些:
[root@localhost webpack]# npm list -g --depth
/root/.nvm/versions/node/v10.15.0/lib
├── npm@6.7.0
├── to@0.2.9
├── update@0.7.4
├── webpack@4.29.0
└── webpack-cli@3.2.1
以上是关于linux下安装webpack遇到的问题的主要内容,如果未能解决你的问题,请参考以下文章