不能 运行 多个项目与离子服务
Cant run multiple projects with ionic serve
我正在使用 ionic2。以下是 ionic info
产生的所有信息。我主要从事两个不同的离子项目,我想同时为他们提供服务。执行 ionic serve
时默认在端口 8000
上加载一个项目。我尝试使用 ionic serve --port 8101
更改第二个端口。但这并没有启动第二个项目。
这是以下错误:
> ionic-hello-world@ ionic:serve /Users/vramos/Workspace/visitorapp
> ionic-app-scripts serve "--port" "8100"
[21:34:57] ionic-app-scripts 0.0.44
[21:34:57] watch started ...
[21:34:57] build dev started ...
[21:34:57] clean started ...
[21:34:57] clean finished in less than 1 ms
[21:34:57] copy started ...
[21:34:57] transpile started ...
events.js:160
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE 0.0.0.0:53703
at Object.exports._errnoException (util.js:1007:11)
at exports._exceptionWithHostPort (util.js:1030:20)
at Server._listen2 (net.js:1253:14)
at listen (net.js:1289:10)
at net.js:1399:9
at _combinedTickCallback (internal/process/next_tick.js:77:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
at Module.runMain (module.js:577:11)
at run (node.js:348:7)
at startup (node.js:140:9)
npm ERR! Darwin 15.6.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run"
"ionic:serve" "--" "--port" "8100"
npm ERR! node v6.2.2
npm ERR! npm v3.9.5
npm ERR! code ELIFECYCLE
npm ERR! ionic-hello-world@ ionic:serve: `ionic-app-scripts serve "
-- port" "8100"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ionic-hello-world@ ionic:serve script 'ionic-
app- scripts serve "--port" "8100"'.
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
ionic-hello- world package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! ionic-app-scripts serve "--port" "8100"
npm ERR! You can get information on how to open an issue for
this project with:
npm ERR! npm bugs ionic-hello-world
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls ionic-hello-world
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/vramos/Workspace/visitorapp/npm-debug.log
There was an error serving your Ionic application: There was
an error with the spawned command: serve
编辑 (11/16/2016):所以 运行 第二个项目 ionic serve --port 3000 --dev-log-server 8101
成功了。不过,我仍然在终端中遇到错误,仅供参考。
错误是
Error: listen EADDRINUSE 0.0.0.0:53703
所以在某些时候 ionic 正在尝试使用不可用的端口 53703。
$ grep -rns 53703 *
node_modules/@ionic/app-scripts/dist/dev-server/dev-server.js:104:var DEV_LOGGER_DEFAULT_PORT = 53703;
当我 运行 你有两个 ionic 实例时,我的系统中没有任何东西使用端口 53703。
据说我是 运行ning ionic-app-scripts 0.0.39,这是 rc2 教程附带的版本。
几个选项:
- 尝试传递另一个开发记录器端口(通过
--dev-logger-port
)
- 使用
lsof
找出占用端口 53703 的进程并终止该进程 (lsof | grep 53703
)
- 尝试将
ionic-app-scripts
降级为 0.0.39
我遇到了同样的问题。
稍加挖掘后发现 livereload-port 使用 35729 端口,dev-logger-port 使用 35703 端口。
运行 解决了问题:
离子服务 --port 8081 --livereload-port 35730 --dev-logger-port 53704
我正在使用 ionic2。以下是 ionic info
产生的所有信息。我主要从事两个不同的离子项目,我想同时为他们提供服务。执行 ionic serve
时默认在端口 8000
上加载一个项目。我尝试使用 ionic serve --port 8101
更改第二个端口。但这并没有启动第二个项目。
这是以下错误:
> ionic-hello-world@ ionic:serve /Users/vramos/Workspace/visitorapp
> ionic-app-scripts serve "--port" "8100"
[21:34:57] ionic-app-scripts 0.0.44
[21:34:57] watch started ...
[21:34:57] build dev started ...
[21:34:57] clean started ...
[21:34:57] clean finished in less than 1 ms
[21:34:57] copy started ...
[21:34:57] transpile started ...
events.js:160
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE 0.0.0.0:53703
at Object.exports._errnoException (util.js:1007:11)
at exports._exceptionWithHostPort (util.js:1030:20)
at Server._listen2 (net.js:1253:14)
at listen (net.js:1289:10)
at net.js:1399:9
at _combinedTickCallback (internal/process/next_tick.js:77:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
at Module.runMain (module.js:577:11)
at run (node.js:348:7)
at startup (node.js:140:9)
npm ERR! Darwin 15.6.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run"
"ionic:serve" "--" "--port" "8100"
npm ERR! node v6.2.2
npm ERR! npm v3.9.5
npm ERR! code ELIFECYCLE
npm ERR! ionic-hello-world@ ionic:serve: `ionic-app-scripts serve "
-- port" "8100"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ionic-hello-world@ ionic:serve script 'ionic-
app- scripts serve "--port" "8100"'.
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
ionic-hello- world package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! ionic-app-scripts serve "--port" "8100"
npm ERR! You can get information on how to open an issue for
this project with:
npm ERR! npm bugs ionic-hello-world
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls ionic-hello-world
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/vramos/Workspace/visitorapp/npm-debug.log
There was an error serving your Ionic application: There was
an error with the spawned command: serve
编辑 (11/16/2016):所以 运行 第二个项目 ionic serve --port 3000 --dev-log-server 8101
成功了。不过,我仍然在终端中遇到错误,仅供参考。
错误是
Error: listen EADDRINUSE 0.0.0.0:53703
所以在某些时候 ionic 正在尝试使用不可用的端口 53703。
$ grep -rns 53703 *
node_modules/@ionic/app-scripts/dist/dev-server/dev-server.js:104:var DEV_LOGGER_DEFAULT_PORT = 53703;
当我 运行 你有两个 ionic 实例时,我的系统中没有任何东西使用端口 53703。
据说我是 运行ning ionic-app-scripts 0.0.39,这是 rc2 教程附带的版本。
几个选项:
- 尝试传递另一个开发记录器端口(通过
--dev-logger-port
) - 使用
lsof
找出占用端口 53703 的进程并终止该进程 (lsof | grep 53703
) - 尝试将
ionic-app-scripts
降级为0.0.39
我遇到了同样的问题。
稍加挖掘后发现 livereload-port 使用 35729 端口,dev-logger-port 使用 35703 端口。
运行 解决了问题: 离子服务 --port 8081 --livereload-port 35730 --dev-logger-port 53704