服务器环境:
[root@node6717 temp]# cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)
[root@node6717 temp]# node -v
v10.11.0
[root@node6717 temp]# npm -v
6.4.1
安装node环境:
安装包下载二进制包:
https://nodejs.org/dist/v10.11.0/node-v10.11.0-linux-x64.tar.xz
tar xf node-v10.11.0-linux-x64.tar.xz
mv node-v10.11.0-linux-x64 /usr/local/
创建软链接:
ln -s /usr/local/node-v10.11.0-linux-x64/bin/node /usr/bin/node
ln -s /usr/local/node-v10.11.0-linux-x64/bin/npm /usr/bin/npm
验证环境:
[root@node6717 temp]# node -v
v10.11.0
[root@node6717 temp]# npm -v
6.4.1
通过npm安装模块:
cd /root/html/
npm i
npm i react-router@2.8.2 #单独安装不同版本的包
配置环境变量:配置node能使用的最大内存:
vim /root/.bash_profile
export NODE_OPTIONS=--max_old_space_size=4096
查看全局的安装包:
npm list -g
查看某个安装包:
$ npm list grunt
projectName@projectVersion /path/to/project/folder
└── grunt@0.4.1
$ npm list | grep grunt
└── grunt@0.4.1
卸载包-直接删除需面的文件夹就可以了:
[root@node86 node_modules]# pwd
/usr/local/node-v10.11.0-linux-x64/lib/node_modules
[root@node86 node_modules]# ls
autoprefixer babel-plugin-react-transform babel-preset-react css-loader npm
babel-core babel-plugin-transform-class-properties babel-preset-stage-0 eslint
babel-loader babel-preset-es2015 cross-env eslint-loader
[root@node86 node_modules]# rm -rf cross-env
[root@node86 node_modules]# ls
autoprefixer babel-plugin-react-transform babel-preset-react css-loader npm
babel-core babel-plugin-transform-class-properties babel-preset-stage-0 eslint
babel-loader babel-preset-es2015 eslint-loader
通过SVN checkout所有文件到目录:
cd /root/html
[root@node6717 html]# svn checkout svn://1.1.1.1//work/trunk --username="abc" --password="123" ./
文件清单:
[root@node6717 html]# ls
app config.js mock package.json webpack.config.js
LICENSE node_modules package-lock.json webpack.production.config.js
查看打包配置文件:
[root@node6717 html]# cat package.json
{
"name": "abc",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "set NODE_ENV=dev && webpack-dev-server --progress --colors",
"mock": "node --harmony ./server/app.js",
"build": "rm -rf ./build && set NODE_ENV=production && webpack --config ./webpack.production.config.js --progress --colors"
},
"author": "",
"license": "ISC",
"devDependencies": {
"autoprefixer": "^6.4.0",
"babel-core": "^6.14.0",
"babel-loader": "^6.2.5",
"babel-plugin-react-transform": "^2.0.2",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.11.1",
"babel-preset-stage-0": "^6.24.1",
"css-loader": "^0.24.0",
"eslint": "^3.4.0",
"eslint-loader": "^1.5.0",
"extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.9.0",
"html-webpack-plugin": "^2.22.0",
"json-loader": "^0.5.4",
"less": "^2.7.1",
"less-loader": "^2.2.3",
"open-browser-webpack-plugin": "0.0.2",
"postcss-loader": "^0.11.0",
"react-transform-hmr": "^1.0.4",
"redux-thunk": "^2.2.0",
"style-loader": "^0.13.1",
"url-loader": "^0.5.7",
"webpack": "^1.13.2",
"webpack-cli": "^3.3.2",
"webpack-dev-server": "^1.15.0",
"webpack-plugin-copy": "^1.0.1"
},
"dependencies": {
"@antv/data-set": "^0.10.1",
"antd": "^2.12.1",
"autobind-decorator": "^2.1.0",
"babel-plugin-import": "^1.2.1",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"bizcharts": "^3.4.1",
"copy-to-clipboard": "^3.0.8",
"es6-promise": "^3.2.1",
"immutable": "^3.8.1",
"koa": "^2.6.1",
"koa-router": "^7.4.0",
"mockjs": "^1.0.1-beta3",
"qs-component": "^0.3.0",
"rc-upload": "^2.4.0",
"react": "^15.6.1",
"react-addons-css-transition-group": "^15.3.1",
"react-addons-pure-render-mixin": "^15.6.0",
"react-anything-sortable": "^1.7.4",
"react-color": "^2.13.8",
"react-copy-to-clipboard": "^5.0.1",
"react-dom": "^15.3.1",
"react-quill": "^1.3.3",
"react-redux": "^4.4.5",
"react-router": "^2.7.0",
"react-smooth-dnd": "^0.5.3",
"react-swipe": "^5.0.5",
"redux": "^3.5.2",
"require-directory": "^2.1.1",
"rsuite": "^2.0.12",
"rsuite-table": "^2.1.1",
"whatwg-fetch": "^1.0.0"
}
}
在当前目录下打包:
cd /root/html/
npm run build
打包完成后的目录 ,会生成build文件夹,这个build文件夹就是打包后生成的文件
将build文件夹里面的文件同步到线上html目录下就可以了
[root@node86 html]# ls
app config.js node_modules package-lock.json server ueditor_bak webpack.production.config.js
build LICENSE package.json public ueditor webpack.config.js