nodejs+webpack packaging

1. Open 

http://nodejs.cn/download/ , select the corresponding system to
download Return the version number npm -v returns the version number 3. Based on node.js, use Taobao npm image to install related dependencies. Since the domestic use of npm will be very slow, it is recommended to use the Taobao NPM mirror (http://npm.taobao.org/) npm install -g cnpm --registry=https://registry.npm.taobao.org After obtaining cnpm , we need to upgrade, enter the following command cnpm install cnpm -g 4. Create npm configuration item Open the directory where the project is located, eg: d:/idea_workspace/idea_vue After going to this directory, enter cnpm init if it is a local beta version, various Enter After that, the basic packaging configuration is complete. 5, install a global webpack cnpm install webpack -g 6, also install a webpack in the project cnpm install webpack --save-dev
































-------------------------------------------------- -----------------------
1. The version number of webpack -v can't come out
Tip :

The CLI moved into a separate package: webpack-cli.
Please install ' webpack-cli' in addition to webpack itself to use the CLI.
-> When using npm: npm install webpack-cli -D
-> When using yarn: yarn add webpack-cli -D


Solution: Install webpack-cli
globally cnpm install webpack-cli -g

will prompt the version number.



Note: Use the webpack command to package and report the following error

: d:\idea_workspace\idea_test\app>
webpack appjs/main.js public/webpack.js Hash: 30a0f72fa4794e4d41bb Version: webpack 4.1.1 Time: 80ms Built at: 2018-3-16 10:17:02 1 asset Entrypoint main = main.js









   [0] ./appjs/work.js 28 bytes {0} [built]
   [1] ./appjs/main.js 20 bytes {0} [built]
   [2] multi ./appjs/main.js public/webpack.js 40 bytes {0} [built]

WARNING in configuration
The 'mode' option has not been set. Set 'mode' option to 'development' or 'production' to enable defaults for this environment.

ERROR in multi ./appjs/main.js public/webpack.js
Module not found: Error: Can't resolve 'public/webpack.js' in 'd:\idea_workspace\idea_test\app'
@ multi ./appjs/main.js public/webpack.js

解决方式:在项目先创建好webpack的入口文件及打包目录,再次输入命令
webpack


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326105306&siteId=291194637