Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

控制台无异常,但是无法访问页面 #5

Closed
junbaor opened this issue Sep 14, 2016 · 21 comments
Closed

控制台无异常,但是无法访问页面 #5

junbaor opened this issue Sep 14, 2016 · 21 comments

Comments

@junbaor
Copy link

junbaor commented Sep 14, 2016

QQ截图20160914212100.png


  1. Frontend 工程的 build 目录是有四个文件的
  2. 在 Frontend Webjars 工程下 执行 mvn install 结果为 BUILD SUCCESS
  3. 使用 mvn clean spring-boot:run 启动 Backend 时控制台如上图所示
  4. 浏览器访问 http://ali.junbaor.com:8080/ 只是出现一个状态码为200的空白页
  5. 访问 http://ali.junbaor.com:8080/test 会出现下图

QQ截图20160914212448.png


@hackape
Copy link
Contributor

hackape commented Sep 14, 2016

@tanhe123 java 这套我不熟,最好你来看一下了。

@hackape
Copy link
Contributor

hackape commented Sep 14, 2016

@junbaor 我先试着答,先试试看 fix 一个东西是 backend /src/main/resources/application.properties 里头 ALLOWED_ORIGIN, 把你域名加上。

@vangie
Copy link
Collaborator

vangie commented Sep 14, 2016

@junbaor 出现状态码为200的页面控制台有没有错误?

@tanhe123
Copy link
Collaborator

访问了一下 http://ali.junbaor.com:8080/user 返回正确结果,说明程序已经成功运行起来了
可以按照 @hackape 的方法添加 ALLOWED_ORIGIN

@junbaor
Copy link
Author

junbaor commented Sep 14, 2016

  1. @vangie 出现状态码为 200 页面时控制台是没有任何信息输出的。
  2. @hackape 已经按所述做出调整,问题依旧。下图是 diff 记录

QQ截图20160914225558.png

@tanhe123
Copy link
Collaborator

帮忙执行下面两句:

cd WebIDE-Workspace/frontend-webjars/target
jar tvf frontend-1.0.0.jar

然后把结果贴一下

@junbaor
Copy link
Author

junbaor commented Sep 14, 2016

@tanhe123

QQ截图20160914232853.png

@tanhe123
Copy link
Collaborator

文件大小不对~
可能是前端 build 出现问题了,可以这样看下:

cd WebIDE-Workspace/frontend/build
cat index.html

@hackape
Copy link
Contributor

hackape commented Sep 14, 2016

我同时提供另外一种思路啊,换种部署方式看看,因为这项目前后端是分离的,可以这样

  1. backend/ide.sh run 让后端跑起来,然后到前端里头 app/config.js 里头有个 baseURL 配置项指向后端地址(现在是 http://ali.junbaor.com:8080)
  2. cd 到 frontend 然后运行 npm start 会默认在 8060 起一个 webpack-dev-server 开发服务器,或者 npm run build 等待编译成静态 build 目录,然后自己 serve 这个目录,这样你 debug 下 build 目录下的静态文件,总能定位问题了

@junbaor
Copy link
Author

junbaor commented Sep 14, 2016

@tanhe123 果然有问题, index.html 文件是空白的
@hackape 我慢慢消化一下 😄

@tanhe123
Copy link
Collaborator

重新 build 前端即可~

@hackape
Copy link
Contributor

hackape commented Sep 14, 2016

  1. cd frontend
  2. npm run build
  3. 检查下编译完的 build 目录是不是正常

先确定这3点吧。

@junbaor
Copy link
Author

junbaor commented Sep 14, 2016

执行 npm run build 就会卡死在这里, 再起个终端 ssh 就会被拒绝。
明天在本地搞个环境试试,感谢各位深夜指导 👍

QQ截图20160914235701.png

@junbaor
Copy link
Author

junbaor commented Sep 15, 2016

抽空在本地起了个虚拟机,前端还是有点问题,尝试 npm rebuild node-sass 无果

npm run build前端项目结果如下:


root@junbaor-virtual:~/coding/WebIDE/frontend# npm run build

> coding-web-ide@1.0.0 build /root/coding/WebIDE/frontend
> NODE_ENV=production ./node_modules/webpack/bin/webpack.js

Hash: d0f5027b790cd3395084
Version: webpack 1.13.2
Time: 75255ms
      Asset       Size  Chunks             Chunk Names
    main.js    1.23 MB       0  [emitted]  main
     1.1.js    4.48 MB       1  [emitted]  
 index.html  753 bytes          [emitted]  
favicon.ico    4.29 kB          [emitted]  
    + 610 hidden modules

ERROR in Cannot find module 'node-sass'
 @ ./app/styles/main.scss 4:14-141
Child html-webpack-plugin for "index.html":
        + 3 hidden modules
root@junbaor-virtual:~/coding/WebIDE/frontend# ll

npm install 的错误信息

root@junbaor-virtual:~/coding/WebIDE/frontend# npm install

> node-sass@3.10.0 install /root/coding/WebIDE/frontend/node_modules/node-sass
> node scripts/install.js

module.js:457
    throw err;
    ^

Error: Cannot find module '/root/coding/WebIDE/frontend/node_modules/node-sass/scripts/install.js'
    at Function.Module._resolveFilename (module.js:455:15)
    at Function.Module._load (module.js:403:25)
    at Module.runMain (module.js:590:10)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:509:3
npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.14
npm WARN coding-web-ide@1.0.0 No repository field.
npm ERR! Linux 4.4.0-21-generic
npm ERR! argv "/lib/nodejs/bin/node" "/lib/nodejs/bin/npm" "install"
npm ERR! node v6.5.0
npm ERR! npm  v3.10.3
npm ERR! code ELIFECYCLE

npm ERR! node-sass@3.10.0 install: `node scripts/install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the node-sass@3.10.0 install script 'node scripts/install.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the node-sass package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node scripts/install.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs node-sass
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls node-sass
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /root/coding/WebIDE/frontend/npm-debug.log

相关版本信息如下:

node -v
v6.5.0

npm -v
3.10.3

python -V
Python 2.7.11+

访问首页源代码如下,但是依然是空白页面:

<!DOCTYPE html>
<html lang="zh-cn">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1,minimum-scale=1, maximum-scale=1">
  <title>Coding WebIDE 开启云端开发模式! -  Coding.net</title>
  <meta name="Keywords" content="Coding.net,Coding,WebIDE,Web IDE,IDE,Git,代码托管,在线开发,在线调试,Terminal,开发环境分享,软件团队协作">
  <meta name="Description" content="Coding WebIDE 是Coding自主研发的在线集成开发环境。用户可以通过WebIDE创建项目的工作空间,进行在线开发,调试等操作。与此同时,WebIDE
    还提供了可分享的开发环境功能,用户可以保存当前的 Terminal 环境,分享给团队的其他成员。">
  <link rel="icon" type="image/x-icon" href="favicon.ico">
  <script src="https://use.fontawesome.com/838df4727b.js"></script>
</head>
<body>
  <div id="root">
  </div>
<script type="text/javascript" src="main.js"></script></body>
</html>

@hackape
Copy link
Contributor

hackape commented Sep 15, 2016

你的 node-sass 没装上,再跑下 npm install node-sass 看看。

@junbaor
Copy link
Author

junbaor commented Sep 15, 2016

@hackape 错误如下,google 好久搞不定 😳

root@junbaor-virtual:~/coding/WebIDE/frontend# npm install node-sass

> node-sass@3.10.0 install /root/coding/WebIDE/frontend/node_modules/node-sass
> node scripts/install.js

module.js:457
    throw err;
    ^

Error: Cannot find module '/root/coding/WebIDE/frontend/node_modules/node-sass/scripts/install.js'
    at Function.Module._resolveFilename (module.js:455:15)
    at Function.Module._load (module.js:403:25)
    at Module.runMain (module.js:590:10)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:509:3
npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.14
npm WARN coding-web-ide@1.0.0 No repository field.
npm ERR! Linux 4.4.0-21-generic
npm ERR! argv "/lib/nodejs/bin/node" "/lib/nodejs/bin/npm" "install" "node-sass"
npm ERR! node v6.5.0
npm ERR! npm  v3.10.3
npm ERR! code ELIFECYCLE

npm ERR! node-sass@3.10.0 install: `node scripts/install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the node-sass@3.10.0 install script 'node scripts/install.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the node-sass package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node scripts/install.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs node-sass
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls node-sass
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /root/coding/WebIDE/frontend/npm-debug.log

@hackape
Copy link
Contributor

hackape commented Sep 15, 2016

sass/node-sass#1484 看到说它对 node 6 不支持,我这边装的是 node v5.6.0 试试看?

@junbaor
Copy link
Author

junbaor commented Sep 15, 2016

刚刚已经尝试着解决了,方式如下:

  1. 全局安装 npm install node-sass -g
  2. cp -r /lib/nodejs/lib/node_modules/node-sass ~/coding/WebIDE/frontend/node_modules/
  3. 重新 build 前端工程 npm run build

build 后文件大小如下:

root@junbaor-virtual:~/coding/WebIDE/frontend# npm run build

> coding-web-ide@1.0.0 build /root/coding/WebIDE/frontend
> NODE_ENV=production ./node_modules/webpack/bin/webpack.js

Hash: efa30b0a10ba9a7721e1
Version: webpack 1.13.2
Time: 75624ms
      Asset       Size  Chunks             Chunk Names
    main.js    1.38 MB       0  [emitted]  main
     1.1.js    4.48 MB       1  [emitted]  
 index.html  753 bytes          [emitted]  
favicon.ico    4.29 kB          [emitted]  
    + 611 hidden modules
Child html-webpack-plugin for "index.html":
        + 3 hidden modules

@hackape 所说的 node 版本问题待会我会重新搭建采用 node v5.6.0 试试

Thank you ! 👍

@junbaor junbaor closed this as completed Sep 15, 2016
@hackape
Copy link
Contributor

hackape commented Sep 15, 2016

@junbaor 你能帮我看看 /lib/nodejs/lib/node_modules/node-sass 的 package.json 里头它的版本号是多少吗?感觉除非是版本有差,不然这不科学啊,没道理全局装就好,local 装就不行的。

@junbaor
Copy link
Author

junbaor commented Sep 15, 2016

@hackape v3.10.0

指的是和 frontend 下 package.json 中 node-sass v3.8.0 这个版本号不一致吗?

@hackape
Copy link
Contributor

hackape commented Sep 19, 2016

@node-sass 的 build 好像经常出平台相关的问题,我索性换成 stylus 了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants