Webpack 安装

简介: Webpack 安装


$ brew install node $ brew install npm


  • 安装完成之后,检查是否安装成功


dengzemiaodeMacBook-Pro:~ dengzemiao$ npm -v 6.13.0 dengzemiaodeMacBook-Pro:~ dengzemiao$ node -v v12.9.1


  • 安装 Webapck、Webpack-cli

1、安装 webpack


// 安装 $ npm install webpack -g // 移除 $ npm uninstall webpack -g ``` dengzemiaodeMacBook-Pro:~ dengzemiao$ npm install webpack -g npm WARN deprecated fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2. /usr/local/bin/webpack -> /usr/local/lib/node_modules/webpack/bin/webpack.js


fsevents@1.2.13 install /usr/local/lib/nodemodules/webpack/nodemodules/watchpack-chokidar2/node_modules/fsevents node install.js


SOLINK_MODULE(target) Release/.node
CXX(target) Release/obj.target/fse/fsevents.o
SOLINK_MODULE(target) Release/fse.node


npm WARN notsup Unsupported engine for watchpack-chokidar2@2.0.0: wanted: {"node":"<8.10.0"} (current: {"node":"12.9.1","npm":"6.13.0"}) npm WARN notsup Not compatible with your version of node/npm: watchpack-chokidar2@2.0.0


  • webpack@4.43.0 added 347 packages from 210 contributors and updated 1 package in 38.597s ```


2、安装 webpack-cli,webpack 现在新版本需要依赖于这个脚手架。


// 安装 $ npm install webpack-cli -g // 移除 $ npm uninstall webpack-cli -g ``` dengzemiaodeMacBook-Pro:~ dengzemiao$ npm install webpack-cli -g /usr/local/bin/webpack-cli -> /usr/local/lib/node_modules/webpack-cli/bin/cli.js npm WARN webpack-cli@3.3.12 requires a peer of webpack@4.x.x but none is installed. You must install peer dependencies yourself.


  • webpack-cli@3.3.12 added 185 packages from 127 contributors in 20.243s ```


3、检查是否安装


// 查看帮助 $ webpack -h // 查看版本 $ webpack -v dengzemiaodeMacBook-Pro:~ dengzemiao$ webpack -v 4.43.0


到这里就安装成功了!!


  • 如果安装中出现这种文件权限错误


npm ERR! Error: EACCES: permission denied, symlink '../lib/node_modules/webpack/bin/webpack.js' -> '/usr/local/bin/webpack'' npm ERR! Please try running this command again as root/Administrator


  • 可以通过打开权限进行,该操作需要输入密码


$ sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}


  • 完成之后重新继续安装。

相关文章
|
5月前
|
JavaScript Windows
安装node.js与webpack创建vue2项目
安装node.js与webpack创建vue2项目
38 1
|
7月前
|
JavaScript 前端开发
webpack成长指北第2章---安装webpack的正确姿势
webpack成长指北第2章---安装webpack的正确姿势
56 0
|
人工智能 JavaScript
nodejs安装webpack详细步骤
nodejs安装webpack详细步骤
|
前端开发
前端学习笔记202303学习笔记第三天-Vue3.0-webpack安装和配置webpack-dev-server
前端学习笔记202303学习笔记第三天-Vue3.0-webpack安装和配置webpack-dev-server
77 0
|
前端开发
前端学习笔记202303学习笔记第二天-安装和配置webpack
前端学习笔记202303学习笔记第二天-安装和配置webpack
72 0
|
前端开发
前端学习笔记202303学习笔记第二天-安装和配置webpack
前端学习笔记202303学习笔记第二天-安装和配置webpack
59 0
|
前端开发
前端学习笔记202303学习笔记第二天-安装和配置webpack2
前端学习笔记202303学习笔记第二天-安装和配置webpack2
62 0
|
JavaScript 前端开发
webpack打包js全局本地安装
webpack打包js全局本地安装
187 0
webpack打包js全局本地安装
Webpack & Webpack-cli 安装成功后查看 webpack -v报错
Webpack & Webpack-cli 安装成功后查看 webpack -v报错
Webpack & Webpack-cli 安装成功后查看 webpack -v报错
|
前端开发 JavaScript API
webpack的安装和使用
为前端工程化而生:webpack致力于解决前端工程化,特别是浏览器端工程化中遇到的问题,让开发者集中注意力编写业务代码,而把工程化过程中的问题全部交给webpack来处理