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

Might be some problems with babel? #1723

Closed
brickyang opened this issue Oct 27, 2015 · 3 comments
Closed

Might be some problems with babel? #1723

brickyang opened this issue Oct 27, 2015 · 3 comments

Comments

@brickyang
Copy link

I has been using PM2 to run and monit node process for a while and it works fine until I try to use babel.

I'm not sure what is the real problem, but when I starting a project with babel, it can't stop showing Port 3000 is already in use.

This project is a copy of another one. They are almost the same except scripts in package.json.

"scripts": {
"start": "npm run babel | node ./bin/www",
"babel": "./node_modules/.bin/babel server -d lib"
}

and the original is much simpler

"scripts": {
"start": "node ./bin/www"
}

I use start the process by run process.json, and add "exec_interpreter": "babel-node" in the project with babel.

I also installed some new packages to the copy project including babel, babel-core, babel-loader, react, react-dom, react-hot-loader, webpack and webpack-dev-server. And I changed the code from ES5 to ES6 like that's why I use babel.(yes, I'm trying to use react and transfer to ES6 based on a normal express project)

When I reboot my mac and run the original project without babel, everything is fine. Then I stop the process and go on to start the project with babel, it keep throwing Port 3000 is already in use.

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
Google 394 brick 14u IPv6 0x432e592f22d3b26b 0t0 TCP localhost:52261->localhost:hbci (CLOSE_WAIT)
Google 394 brick 16u IPv6 0x432e592f22d397ab 0t0 TCP localhost:52262->localhost:hbci (CLOSE_WAIT)
Google 394 brick 213u IPv6 0x432e592f246f87ab 0t0 TCP localhost:52264->localhost:hbci (CLOSE_WAIT)
node 1210 brick 13u IPv6 0x432e592f22d377ab 0t0 TCP *:hbci (LISTEN)

I use lsof -i:3000 in shell, it shows there's a node process and 2-3 named Google processes(I'm using chrome) is using the port. Even I killed the process, it reappears(with different pid).

I have no idea what's the problem.

@soyuka
Copy link
Collaborator

soyuka commented Oct 28, 2015

Are you using the fork mode? Please take a look at this issue where I give some workarounds to use babel.

@soyuka soyuka closed this as completed Oct 28, 2015
@brickyang
Copy link
Author

@soyuka Thx. It seems work.(btw, the link you suggest has a wrong href

@brickyang
Copy link
Author

@soyuka Sorry, I tried the exec_interpreter:babel-node and the require hook, but it seems can't help with the port occupying problem. I'm using Express 4, the entry is ./bin/www, and I use pm2-dev run process.json to start it. I put the require hook in the top of the ./bin/www, and the process.json is like

{
"apps": [{
"name": "rewechat",
"script": "./bin/www",
"node_args": "--harmony",
"watch": true,
"log_date_format": "YYYY-MM-DD HH:mm Z",
exec_interpreter:babel-node
}]
}

what did I miss?

I'm also confusing that if I use process.json to start ./www/bin, does the package.jsonwork? Or it will be ignored?

Thx

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

2 participants