在寻址到dev服务器运行期间,ionic2失败(离子问候世界)

Вол*_*мир 3 javascript cordova ionic2

ionic2 hello world不起作用.

我正在关注官方网站开始 - https://ionicframework.com/docs/v2/intro/tutorial/

install cordova and ionic
ionic start probaionic --v2
cd probaionic
ionic serve
Run Code Online (Sandbox Code Playgroud)

一切正常 - 开发服务器运行:http:// localhost:8100 /

当我尝试解决此URL时,我收到此错误:

traineeProgram/probaionic/node_modules/@ionic/app-scripts/dist/dev-server      /live-reload.js:27
var contentStr = content.toString();
                        ^

TypeError: Cannot read property 'toString' of undefined
at Object.injectLiveReloadScript (/media/volodymyr/Media/[[1]] work/[8]programming/[1]keenethics/traineeProgram/probaionic/node_modules/@ionic/app-scripts/dist/dev-server/live-reload.js:27:29)
at ReadFileContext.callback (/media/volodymyr/Media/[[1]] work/[8]programming/[1]keenethics/traineeProgram/probaionic/node_modules/@ionic/app-scripts/dist/dev-server/http-server.js:62:39)
at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:365:13)

npm ERR! Linux 4.4.0-57-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "ionic:serve" "--" "--v2" "--address" "0.0.0.0" "--port" "8100" "--livereload-port" "35729"
npm ERR! node v6.9.5
npm ERR! npm  v4.1.2
npm ERR! code ELIFECYCLE
npm ERR! ionic-hello-world@ ionic:serve: `ionic-app-scripts serve "--v2" "--address" "0.0.0.0" "--port" "8100" "--livereload-port" "35729"`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the ionic-hello-world@ ionic:serve script 'ionic-app-scripts serve "--v2" "--address" "0.0.0.0" "--port" "8100" "--livereload-port" "35729"'.
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 "--v2" "--address" "0.0.0.0" "--port" "8100" "--livereload-port" "35729"
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.
Run Code Online (Sandbox Code Playgroud)

小智 6

我在下面的警告中遇到了同样的问题

******************************************************依赖性警告 - 为了使CLI正常运行,强烈建议安装/升级以下内容:请将Cordova CLI安装到版本> = 4.2.0 npm install -g cordova安装ios-sim以部署iOS应用程序.npm install -g ios-sim(可能需要sudo)安装ios-deploy以将iOS应用程序部署到设备.npm install -g ios-deploy(可能需要sudo)


尝试,运行cordova -v命令,您将选择以下问题

? May Cordova anonymously report usage statistics to improve the tool over time? No

我没用,它显示版本是6.5.0

You have been opted out of telemetry. To change this, run: cordova telemetry on. 6.5.0

ionic serve再次运行命令,它工作正常.

  • 诀窍:'科尔多瓦遥测'也对我有用......这很奇怪,就像走出去开车引擎......¯\ _(ツ)_ /¯ (2认同)