Ionic-cli: Generating page returns 'no such file or directory, scandir '<proj_root>\src\pages\node_modules\ionic-angular\templates\page''

Created on 27 Jul 2017  路  13Comments  路  Source: ionic-team/ionic-cli

Hi,

Generating a page with this cli command ionic generate page <page-name> returns
Error: ENOENT: no such file or directory, scandir '<proj_root>\src\pages\node_modules\ionic-angular\templates\page'.

Most helpful comment

Oh, I see. You're running the command in a subdirectory and app-scripts doesn't yet support that. '<proj_root>\src\pages\node_modules\ionic-angular\templates\page'

Move to your project root and re-run the command.

Running these commands is on my list of things todo, but unfortunately that list is quite long

All 13 comments

@sylvaingirardbe Please fill out the issue template. We need you to run ionic info.

Ok, here goes:

Description:
Generating a page with this cli command ionic generate page <page-name> returns
Error: ENOENT: no such file or directory, scandir '<proj_root>\src\pages\node_modules\ionic-angular\templates\page'.

Steps to Reproduce:

  1. npm install -g cordova ionic
  2. ionic start <project> sidemenu
  3. cd <project>
  4. ionic login
  5. ionic link
  6. ionic serve
  7. Install all updates
  8. In another powershell window ionic generate page <page-name>

Output:
[DEBUG] CLI flags: { interactive: true, confirm: false } [DEBUG] { cwd: '<proj_root>\\src\\pages', local: true, binPath: 'C:\\Users\\SylvainGirard\\AppData\\Roaming\\npm\\node_modules\\ionic\\bin\\ionic', libPath: '<proj_root>\\node_modules\\ionic\\dist\\index.js' } [DEBUG] Loading local plugin @ionic/cli-plugin-proxy [DEBUG] Throwing PLUGIN_NOT_INSTALLED for local @ionic/cli-plugin-proxy [DEBUG] Loading local plugin @ionic/cli-plugin-ionic-angular [DEBUG] Daemon found (pid: 16296) [DEBUG] Getting plugin info for ionic [DEBUG] Checking for latest plugin version of ionic@latest. [DEBUG] Getting plugin info for @ionic/cli-plugin-ionic-angular [DEBUG] Checking for latest plugin version of @ionic/cli-plugin-ionic-angular@latest. Error: ENOENT: no such file or directory, scandir '<proj_root>\src\pages\node_modules\ionic-angular\templates\page' [DEBUG] Error: ENOENT: no such file or directory, scandir '<proj_root>\src\pages\node_modules\ionic-angular\templates\page' at Error (native) at Object.fs.readdirSync (fs.js:952:18) at readTemplates (<proj_root>\node_modules\@ionic\app-scripts\dist\generators\util.js:47:26) at Object.generateTemplates (<proj_root>\node_modules\@ionic\app-scripts\dist\generators\util.js:188:12) at Object.processPageRequest (<proj_root>\node_modules\@ionic\app-scripts\dist\generators.js:8:19) at Object.<anonymous> (<proj_root>\node_modules\@ionic\cli-plugin-ionic-angular\dist\generate.js:32:34) at next (native) at fulfilled (<proj_root>\node_modules\tslib\tslib.js:93:62)

My ionic info:
cli packages:

@ionic/cli-plugin-ionic-angular : 1.4.0 (<proj_root>\node_modules\@ionic\cli-plugin-ionic-angular)
@ionic/cli-utils                : 1.6.0 (<proj_root>\node_modules\@ionic\cli-utils)
ionic (Ionic CLI)               : 3.6.0 (<proj_root>\node_modules\ionic)

local packages:

@ionic/app-scripts : 2.0.2
Ionic Framework    : ionic-angular 3.5.3

System:

Node : v6.11.0
OS   : Windows 10
npm  : 3.10.10

Hmm, try updating your app-scripts. There was a release today with generator features.

npm i @ionic/app-scripts@latest

Didn't help...

Oh, I see. You're running the command in a subdirectory and app-scripts doesn't yet support that. '<proj_root>\src\pages\node_modules\ionic-angular\templates\page'

Move to your project root and re-run the command.

Running these commands is on my list of things todo, but unfortunately that list is quite long

I am using ionic cli version 3.9.2. Still an issue if I don't run the command in the project root.

Yep. There will be updates to the CLI that don't have this fix for quite some time, as it's super low priority for me. I am always accepting PRs.

Is this issue fixed now Or still we have to wait?

@abacusInfosys This will be fixed for CLI v4.

You can test the fix by installing the alpha CLI: npm i -g ionic@canary

Go to the root folder of your project and try again.

Hi,
On the root it is working fine. Main concern was if I create sub directory and fire page generation command, it throws error-

Error: ENOENT: no such file or directory, scandir 'MypathProjectsrcpagesMyModulenode_modulesionic-angulartemplatespage'
at Error (native)
at Object.fs.readdirSync (fs.js:952:18)
at readTemplates ([email protected]:115:26)
at Object.generateTemplates ([email protected]:287:12)
at Object.processPageRequest ([email protected]:9:23)
at GenerateRunner.
(C:UsersMyUSerAppDataRoamingnpmnode_modulesionicnode_modules@ioniccli-utilslibprojectionic-angulargenerate.js:96:38)
at next (native)
at fulfilled (C:UsersMyUsersAppDataRoamingnpmnode_modulesionicnode_modulestslibtslib.js:104:62)

it is still observed with CLI 4 alpha

@abacusInfosys I'm sorry about that--please try updating the alpha CLI again. I just added a fix.

@dwieeb Ok now page is created successfully No error observed, however it is created in the root itself.
Is it possible to create a page in subdirectory from which command is executed- Like

G:Source_CodeMyProjectsrcpagesLoginModule> ionic generate page login
should create page in LoginModule folder, not in Pages folder.

OR something like providing complete path in the command where page needs to be created -

G:Source_CodeMyProjectsrcpages> ionic generate page 'LoginModulelogin'

Was this page helpful?
0 / 5 - 0 ratings