Skip to content
This repository has been archived by the owner on Aug 24, 2019. It is now read-only.

执行npm run build命令,会卡在Starting 'bundle'... #1

Closed
forrest23 opened this issue Dec 14, 2016 · 9 comments
Closed

执行npm run build命令,会卡在Starting 'bundle'... #1

forrest23 opened this issue Dec 14, 2016 · 9 comments

Comments

@forrest23
Copy link

执行npm run build命令,会卡在Starting 'bundle'...不动。整个虚拟主机都卡死的感觉,什么情况?

@lisong
Copy link
Owner

lisong commented Dec 14, 2016

image

比较耗时,但没有出现过你说卡死的情况

@forrest23
Copy link
Author

forrest23 commented Dec 15, 2016

应该是我服务器上node版本太新了造成的。我服务器上是7.2版本的。后来我在本机编译时可以正常编译的。但是发现一个跨域的问题,code-push-web需要访问code-push-server的readme.md,因为我是发布在两个端口,所有访问不了 ,然后就报错了@lisong

@lisong
Copy link
Owner

lisong commented Dec 15, 2016

code-push-server端要设置
如果用nginx做code-push-server loadbalance,配置如下,$other_domain 里面要改成你code-push-web地址,非80端口,不要忘记加上端口号

map $http_origin $other_domain {
     default       0;
     "~http://codepush-managerment.19910225.com:8080" http://codepush-managerment.19910225.com:8080;
     "~http://localhost:3000" http://localhost:3000;
}
server {
    listen 8080;
    server_name codepush.19910225.com;

    location / {
        add_header Access-Control-Allow-Origin $other_domain always;
        add_header Access-Control-Allow-Credentials true always;
        if ($request_method = "OPTIONS") {
            add_header 'Access-Control-Allow-Origin' $other_domain always;
            add_header 'Access-Control-Allow-Credentials' true always;
            add_header 'Access-Control-Max-Age' 86400 always;
            add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, DELETE, PATCH' always;
            add_header 'Access-Control-Allow-Headers' 'reqid, nid, host, x-real-ip, x-forwarded-ip, event-type, event-id, accept, content-type, x-requested-with, origin, authorization' always;
            add_header 'Content-Length' 0 always;
            add_header 'Content-Type' 'text/plain, charset=utf-8' always;
            return 204;
        }
        client_max_body_size 100m;
        proxy_pass http://app-codepushsong;
    }
}

@lisong
Copy link
Owner

lisong commented Dec 15, 2016

code-push-server 在development环境下加了跨域设置, 查看项目中app.js

//use nginx in production
if (app.get('env') === 'development') {
  app.all('*', function(req, res, next) {
    res.header("Access-Control-Allow-Origin", "*");
    res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Authorization");
    res.header("Access-Control-Allow-Methods","PUT,POST,GET,PATCH,DELETE,OPTIONS");
    next();
  });
}

@forrest23
Copy link
Author

@lisong proxy_pass http://app-codepushsong; 这句话是什么意思?

@lisong
Copy link
Owner

lisong commented Dec 15, 2016

我这边nginx定义了upstream

upstream app-codepushsong {
   server 127.0.0.1:3001;
}

如果只开了一个code-push-server实例,可以直接

proxy_pass http://127.0.0.1:3001;

@forrest23
Copy link
Author

跨域的问题好了,谢谢!在注册的时候,发邮件验证码,我已经改了smtpConfig中的配置,但是在发邮件的时候提示 Stream connection ended and command aborted. @lisong

@lisong
Copy link
Owner

lisong commented Dec 15, 2016

没有配置redis服务,因为验证码是放在redis服务上

@youngjuning
Copy link

按照配置指引,还是没有解决跨域问题。@forrest23 能分享下你的配置吗

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

No branches or pull requests

3 participants