前端项目 npm run build 报错如下,本地打包没有问题,在centos服务器打包报错

提问 10 5168
shengke
shengke VIP3 2018-08-25
版本:renren-security 企业版前后端分离 开发环境:
企业版前端项目,npm run build 报错如下,本地打包没有问题,在centos服务器打包报错, 我把服务器上的node版本换成和本地的一样,也不能打包成功 [pre] ERROR in ./src/views/modules/home.vue Module build failed: TypeError: Cannot read property 'range' of null at SourceCode.getTokenBefore (/home/di/git/coffee-admin-vue/node_modules/eslint/lib/token-store/index.js:303:18) at checkSpacingBefore (/home/di/git/coffee-admin-vue/node_modules/eslint/lib/rules/template-curly-spacing.js:52:42) at TemplateElement (/home/di/git/coffee-admin-vue/node_modules/eslint/lib/rules/template-curly-spacing.js:117:17) at listeners.(anonymous function).forEach.listener (/home/di/git/coffee-admin-vue/node_modules/eslint/lib/util/safe-emitter.js:47:58) at Array.forEach (<anonymous>) at Object.emit (/home/di/git/coffee-admin-vue/node_modules/eslint/lib/util/safe-emitter.js:47:38) at NodeEventGenerator.applySelector (/home/di/git/coffee-admin-vue/node_modules/eslint/lib/util/node-event-generator.js:251:26) at NodeEventGenerator.applySelectors (/home/di/git/coffee-admin-vue/node_modules/eslint/lib/util/node-event-generator.js:280:22) at NodeEventGenerator.enterNode (/home/di/git/coffee-admin-vue/node_modules/eslint/lib/util/node-event-generator.js:294:14) at CodePathAnalyzer.enterNode (/home/di/git/coffee-admin-vue/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:608:23) at Traverser.enter [as _enter] (/home/di/git/coffee-admin-vue/node_modules/eslint/lib/linter.js:865:28) at Traverser._traverse (/home/di/git/coffee-admin-vue/node_modules/eslint/lib/util/traverser.js:132:14) at Traverser._traverse (/home/di/git/coffee-admin-vue/node_modules/eslint/lib/util/traverser.js:144:34) at Traverser._traverse (/home/di/git/coffee-admin-vue/node_modules/eslint/lib/util/traverser.js:144:34) at Traverser._traverse (/home/di/git/coffee-admin-vue/node_modules/eslint/lib/util/traverser.js:147:30) at Traverser._traverse (/home/di/git/coffee-admin-vue/node_modules/eslint/lib/util/traverser.js:147:30) @ ./src/router/index.js 35:13-43 @ ./src/main.js @ multi babel-polyfill ./src/main.js ERROR in ./src/views/common/login.vue Module build failed: TypeError: Cannot read property 'range' of null at SourceCode.getTokenBefore (/home/di/git/coffee-admin-vue/node_modules/eslint/lib/token-store/index.js:303:18) at checkSpacingBefore (/home/di/git/coffee-admin-vue/node_modules/eslint/lib/rules/template-curly-spacing.js:52:42) at TemplateElement (/home/di/git/coffee-admin-vue/node_modules/eslint/lib/rules/template-curly-spacing.js:117:17) at listeners.(anonymous function).forEach.listener (/home/di/git/coffee-admin-vue/node_modules/eslint/lib/util/safe-emitter.js:47:58) at Array.forEach (<anonymous>) at Object.emit (/home/di/git/coffee-admin-vue/node_modules/eslint/lib/util/safe-emitter.js:47:38) at NodeEventGenerator.applySelector (/home/di/git/coffee-admin-vue/node_modules/eslint/lib/util/node-event-generator.js:251:26) at NodeEventGenerator.applySelectors (/home/di/git/coffee-admin-vue/node_modules/eslint/lib/util/node-event-generator.js:280:22) at NodeEventGenerator.enterNode (/home/di/git/coffee-admin-vue/node_modules/eslint/lib/util/node-event-generator.js:294:14) at CodePathAnalyzer.enterNode (/home/di/git/coffee-admin-vue/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:608:23) at Traverser.enter [as _enter] (/home/di/git/coffee-admin-vue/node_modules/eslint/lib/linter.js:865:28) at Traverser._traverse (/home/di/git/coffee-admin-vue/node_modules/eslint/lib/util/traverser.js:132:14) at Traverser._traverse (/home/di/git/coffee-admin-vue/node_modules/eslint/lib/util/traverser.js:144:34) at Traverser._traverse (/home/di/git/coffee-admin-vue/node_modules/eslint/lib/util/traverser.js:144:34) at Traverser._traverse (/home/di/git/coffee-admin-vue/node_modules/eslint/lib/util/traverser.js:147:30) at Traverser._traverse (/home/di/git/coffee-admin-vue/node_modules/eslint/lib/util/traverser.js:147:30) @ ./src/router/index.js 15:11-41 @ ./src/main.js @ multi babel-polyfill ./src/main.js Build failed with errors. npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! coffee-admin-vue@1.0.0 build: `node build/build.js` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the coffee-admin-vue@1.0.0 build 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! /home/di/.npm/_logs/2018-08-25T07_27_03_951Z-debug.log [di@web coffee-admin-vue]$ [/pre] img[//cdn.renren.io/d8280201808251546545409.png]
本帖标签: 打包失败
回帖
  • daxiong
    2018-08-26
    抱歉,并没有尝试和测试过在centos服务器打包! 还有为什么需要在服务器打包?难道你开发也在服务器开发?
    0
  • shengke
    2018-08-26
    @daxiong 前端项目源码通过git同步到生产环境,然后就在生产环境打包发布的;难道是在本地打包后,编译后的再传到git,同步的生产环境嘛
    0
  • daxiong
    2018-08-27
    亲,你下载下 renren-security企业版(前后端分离)v1.1.1版本。主要是添加项目插件版本锁。 img[//cdn.renren.io/c6413201808270918354918.png] 你可以先直接将package.json文件中的 "babel-eslint": "^8.2.1" 修改成 "babel-eslint": "8.0.1",再npm install安装下.
    0
  • shengke
    2018-08-27
    @daxiong 老大改了 "babel-eslint": "^8.2.1" 修改成 "babel-eslint": "8.0.1",还是不行啊,npm install完美安装,就是npm run build 还是和上面描述的错误一样,要不您上服务器上看看face[害羞]
    0
  • daxiong
    2018-08-27
    稍等,服务器在尝试中...
    0
  • @shengke 使用阿里云的服务器,CentOS7.4系统,没有出现问题,可正常打包,如下: img[//cdn.renren.io/bdc28201808271213442634.jpg] img[//cdn.renren.io/636a3201808271213503246.jpg]
    0
  • shengke
    2018-08-27
    @Mark 我把没有改过的源码,分别在服务器上测试了 security-enterprise-FrontBackSplit_1.1.1 这个版本 npm run build 没有问题 security-enterprise-FrontBackSplit_1.1.0 这个版本 npm run build 报错 您测试的也是security-enterprise-FrontBackSplit_1.1.1 这个版本吧
    0
  • @shengke 是的,使用的是1.1.1
    0
  • shengke
    2018-08-27
    @Mark 1.1.1 和1.1.0 后台代码有改动吗,不行的话前台我就换成1.1.1的
    0
  • shengke
    2018-08-27
    @Mark 已经将前台替换,目前没有问题
    0
本帖已结贴