ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
#### npm常用命令: npm init 在项目中引导创建一个**package.json**文件 npm install 安装模块 ``` npm install webpack@4.0.1 --save|--save-dev -g 安装的包写到package.json的dependencies或devDependencies 如果不指定包名则根据package.json的配置来安装 -g:?? ``` npm uninstall 卸载模块 npm run dev:执行脚本,dev对应package.json中的scripts npm update 更新模块 npm outdated 检查模块是否已经过时 npm ls 查看安装的模块 npm help 查看某条命令的详细帮助 npm root 查看包的安装路径 npm config 管理npm的配置路径 npm cache 管理模块的缓存 npm start 启动模块 npm stop 停止模块 npm restart 重新启动模块 npm test 测试模块 npm version 查看模块版本 npm view 查看模块的注册信息 npm adduser 用户登录 npm publish 发布模块 npm access 在发布的包上设置访问级别 #### package.json ```json { "name": "zyy", "version": "1.0.1", "description": "my first demo", "main": "index.js", "scripts": { "dev": "webpack-dev-server --open", "build": "webpack" }, "author": "", "license": "MIT", "dependencies": { "css-loader": "^2.1.1" } } ``` **webpack**: 安装webpack:*npm i -webpack* #### webpack常用命令 ``` webpack – building for development webpack -p – building for production (minification) webpack --watch – for continuous incremental building webpack -d – including source maps webpack --colors – making building output pretty ``` #### webpack.config.js ```javascript module.exports = { //单个人口文件 entry: './main.js', output: { filename: 'bundle.js' }, //多个入口文件 entry: {boundle1:'./main1.js',boundle2:'./main2.js'}, output: { filename: '[name].js' }, module: { rules:[ { test: /\.css$/, exclude: /node_modules/, use: [ 'style-loader', 'css-loader' ] }, ], rules:[ { test: /\.(png|jpg)$/, use: [ { loader: 'url-loader', options: { limit: 8192 } } ] } ] } }; ```