CentOS7下使用CNPM進行NPM、WEBPACK打包
阿新 • • 發佈:2019-02-11
這兩天大家反映測試伺服器的NPM打包不行,影響了測試環境的自動整合,所以花時間解決了這個問題,因為不能翻,主要使用的阿里的CNPM。
遇到的坑不一一解釋,如下是用到的命令的彙總:
#清空快取 rm -rf /root/.npm #先把Node安裝包放到/usr/local/下 cd /usr/local xz -d /usr/local/node-v8.9.3-linux-x64.tar.xz tar xvf node-v8.9.3-linux-x64.tar #刪除舊的連結 rm -f /usr/local/bin/node rm -f /usr/local/bin/npm ln -s /usr/local/node-v8.9.3-linux-x64/bin/node /usr/local/bin/node node -v ln -s /usr/local/node-v8.9.3-linux-x64/bin/npm /usr/local/bin/npm export NODE_ENV=production export HOST_ENV=http://192.168.14.98:2555 npm cache clean npm cache verify #安裝cnpm npm install -g cnpm --registry=https://registry.npm.taobao.org npm install -g webpack --registry=https://registry.npm.taobao.org ln -s /usr/local/node-v8.9.3-linux-x64/bin/webpack /usr/bin/webpack ln -s /usr/local/node-v8.9.3-linux-x64/bin/cnpm /usr/bin/cnpm cnpm install cnpm install webpack webpack --config /var/tmp/web/build/webpack.dll.config.js --progress #安裝各種包 cnpm install clean-webpack-plugin cnpm install extract-text-webpack-plugin cnpm install webpack-merge cnpm install add-asset-html-webpack-plugin cnpm install react-hot-loader cnpm install babel-loader cnpm install babel-core cnpm i babel-plugin-transform-decorators-legacy cnpm i transform-runtime cnpm i babel-plugin-transform-runtime npm i babel-plugin-import cnpm i babel-plugin-import cnpm i babel-preset-es2015 cnpm i babel-stage-0 cnpm i babel-preset-stage-0 webpack --config /var/tmp/web/build/webpack.dll.config.js --progress cnpm ibabel-preset-react cnpm i babel-preset-react cnpm install style-loader --save cnpm install css-loader --save cnpm install file-loader --save cnpm install url-loader --save cnpm install less-loader --save cnpm install less --save webpack --config /var/tmp/web/build/webpack.config.js --env=prod --progress --profile --colors
打包測試程式碼地址: https://github.com/wangfei0904306/npm-pack-test