How to fix "ReferenceError : ionic is not defined" when I run command `ionic serve --lab`?

How to fix "ReferenceError : ionic is not defined" when I run command `ionic serve --lab`?

我已经在 Yeoman 中创建了一个 Ionic 项目。当 ionic serve 命令显示多个地址时,我选择了 localhost 选项。但是当我 运行 应用程序时,它在控制台上显示错误

   ReferenceError : ionic is not defined

这是我正在关注的完整过程 -

   Running live reload server: http://localhost:35729
   Watching : [ 'www/**/*', '!www/lib/**/*' ]
   Running dev server: http://localhost:8100
   Ionic server commands, enter:
   restart or r to restart the client app from the root
   goto or g and a url to have the app navigate to the given url
   consolelogs or c to enable/disable console log output
   serverlogs or s to enable/disable server log output
   quit or q to shutdown the server and exit

   ionic $ c
   Console log output: enabled
   Loading: /?restart=998712
   ionic $ 0     129599   error    ReferenceError: ionic is not defined,       http://localhost:8100/?ionicplatform=ios, Line: 103
    0     129653   error    ReferenceError: ionic is not defined,   http://localhost:8100/?ionicplatform=android, Line: 103

我不明白为什么这个错误会在控制台上闪烁。 Ionic 安装在我的系统上,我使用 ionic 命令测试了它 运行。这是我得到的错误的屏幕截图。我也检查了系统中的ionic.config文件,它的服务器地址已经存在

  "ionicServeAddress": "localhost"

您已经通过两种方式解决了您的问题。

  1. 删除 node_modules 然后 运行 npm update
  2. 正在重新安装gulp(但你应该安装全局)

    npm install -g gulp
    

我在管理员模式下重新创建了 yeomen 项目结构,它成功了。