Ionic 2 - 无法通过CLI生成页面如何解决错误?

时间:2016-09-17 07:09:52

标签: angularjs ionic-framework ionic2

这可能只是我缺乏使用离子2的经验,但是我在通过CLI生成页面时遇到错误。

我使用的语法:"离子g页面TestPage"

它返回错误(如下)。有谁知道如何解决此错误?似乎"模板"我的机器上不存在目录,我收集的是为什么会发生这种情况,但不确定如何将其存在或解决问题。路径的第一部分确实存在:C:\ apps \ sampleapp \ node_modules \ ionic-angular \,但不是" templates / page"一部分。

Error: ENOENT: no such file or directory, scandir 'C:\apps\sampleapp\node_modules\ionic-angular\templates\page'
at Error (native)
at Object.fs.readdirSync (fs.js:808:18)
at getTemplatesInDir (C:\Users\m411\AppData\Roaming\npm\node_modules\ionic\node_modules\@ionic\app-generator
at Generator.renderAndWriteTemplates (C:\Users\m411\AppData\Roaming\npm\node_modules\ionic\node_modules\@ion
at C:\Users\m411\AppData\Roaming\npm\node_modules\ionic\node_modules\@ionic\app-generators\index.js:25304:26

Ionic Framework版本:2.0.0-beta.11

Ionic CLI版本:2.1.0-beta.1

Ionic App Lib版本:2.1.0-beta.0

操作系统:Windows 8.1

节点版本:v4.5.0

4 个答案:

答案 0 :(得分:2)

将您的离子版本降级为测试版22 ..我认为通过卸载然后更新npm以防万一,然后重新安装较低的离子版本。

How do you completely remove Ionic and Cordova installation from mac?

我建议尝试" npm install"在此之后的项目目录中。

答案 1 :(得分:0)

npm i -g ionic@2.0.0 - 解决了这个问题。

谢谢。

答案 2 :(得分:0)

好的,对于那些不能选择降级的人来说:

Ionic团队做了一些主要的API更新和一些重组。 您需要遵循以下升级步骤:

旁注:如果您确实卸载并重新安装了软件包并且确实使用sudo运行命令并在同一终端中点击命令ionic start --v2 myApp,那么您需要使用以下命令更新文件夹中的权限: sudo chown -R username ./pathToAppFolder

https://github.com/driftyco/ionic/blob/master/CHANGELOG.md#steps-to-upgrade-to-rc0

答案 3 :(得分:0)

npm i -g ionic@2.0.0-beta.37为我解决了这个问题,以前是关于离子2.0.0 beta 11