1.配置完,node环境后,使用命令如下
npm install -g pm2 会报一些警告,原因是有些依赖包是window版本与系统版本不同
一下是一些错误以及解决方法
npm notice createdalockfileaspackage-lock.json. You should commit thisfile.
npm WARN fsevents@1.2.0had bundled packages thatdonotmatchtherequiredversion(s). They have been replacedwithnon-bundled versions.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.0(node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupportedplatformforfsevents@1.2.0: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
原因:
fsevents不在package.json里,但是仍然安装了,是因为你的系统不是Windows系统,fsevents是苹果系统的可选依赖,你的项目有可能是团队项目,别人在他的mac上安装了fsevents相关依赖库,所以到这边你也就安装到你的windows上边了。你可以检查你的package.json 文件中是不是有fsevents相关依赖,删除即好!
如果没有,删除node_modules文件夹,重新安装各项依赖就好了(此处影响不大可以忽略)
2.pm2没有做软连接,要对pm2进行软连接访问
[root@localhost bin]# ln -s /root/node-v10.9.0-linux-x64/bin/pm2 /usr/local/bin/pm2
[root@localhost bin]# ln -s /root/node-v10.9.0-linux-x64/bin/pm2-dev /usr/local/bin/pm2-dev
[root@localhost bin]# ln -s /root/node-v10.9.0-linux-x64/bin/pm2-docker /usr/local/bin/pm2-docker
ln -s /root/node-v10.9.0-linux-x64/bin/pm2-runtime /usr/local/bin/pm2-runtime
3.ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! metools@1.0.0 dev: `node build/dev-server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the metools@1.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\think\AppData\Roaming\npm-cache\_logs\2018-03-29T02_46_46_622Z-debug.log
(注意由于node环境的版本过高难免会有BUG此时删除新版本下载旧版本即可)
2.1 确认服务器安装了 node 环境
npm install -g pm2#安装node进程管理工具pm2 logs#查看进程日志pm2 list#查看各个进程
#进入agent目录,安装依赖npm install#运行agentpm2 start main.js
2.3 build api
#进入api目录,安装依赖cd servicenpm install#编译代码npm run webpack#运行apipm2 start dist/server.js
2.4 build web
#进入web目录,安装依赖cd webnpm install#运行web程序npm run start