Hello, I am trying to create a new blank ionic angular project, but I am unable to create it in the CLI without this error.
> capacitor.cmd init ia-proj io.ionic.starter --web-dir www
'Web' is not recognized as an internal or external command,
operable program or batch file.
'Angular\ia-proj\node_modules\.bin\' is not recognized as an internal or external command,
operable program or batch file.
node:internal/modules/cjs/loader:998
Which I believe causes this error when I try to run ionic serve
on the project after it has been created:
> ionic serve
> ng.cmd run app:serve --host=localhost --port=8100
[ng] 'Web' is not recognized as an internal or external command,
[ng] operable program or batch file.
[ng] 'Angular\ia-proj\node_modules\.bin\' is not recognized as an internal or external command,
[ng] operable program or batch file.
[ng] node:internal/modules/cjs/loader:998
Sme more information:
Ionic CLi version: 6.20.5
Angular CLI: 15.0.3
Node: 18.12.1
Package Manager: npm 8.19.2
I am unsure what is causing this issue and how to fix it or work around it, any help is appreciated.
Edit: I am able to run it with ng serve
, but I get the exact same error when I try to run ionic g c recipes
you need to build before serving and then sync.
ionic build
npx cap sync
The same error above occurs on ionic build
and npx cap sync
.
'Web' is not recognized as an internal or external command,
operable program or batch file.
'Angular\ia-proj\node_modules\.bin\' is not recognized as an internal or external command,
operable program or batch file.
node:internal/modules/cjs/loader:998
Delete your node modules, Android, iOS folders and run npm install and then run those commands above. this should fix the issue.
Sorry to say, same issue. I deleted the node_modules folder in the project. There was no iOS or Android folders in the project, and then I ran npm install. After running npm install, then running ionic build, same error. Ngx cap sync, same error as well.
Hey, just getting around to this. What steps could I take to try and reproduce?
Hello, I did what was specified in the installation guide.
I already had node and npm installed, so I ran npm install -g @ionic/cli
in powershell. The installation had no issues.
Then I ran ionic start
, selected Not to use the wizard, Angular, Blank template, and named the project ia-proj.
During the initialization of the project, I got this error, which is the same error which occurs on any ionic command for me.
> capacitor.cmd init ia-proj io.ionic.starter --web-dir www
'Web' is not recognized as an internal or external command,
operable program or batch file.
'Angular\ia-proj\node_modules\.bin\' is not recognized as an internal or external command,
operable program or batch file.
node:internal/modules/cjs/loader:998
throw err;
^
Error: Cannot find module 'C:\Users\sworley\Documents\Udemy\@capacitor\cli\bin\capacitor'
at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
at Module._load (node:internal/modules/cjs/loader:841:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
On Ionic build
ionic build
> ng.cmd run app:build
'Web' is not recognized as an internal or external command,
operable program or batch file.
'Angular\ia-proj\node_modules\.bin\' is not recognized as an internal or external command,
operable program or batch file.
node:internal/modules/cjs/loader:998
throw err;
^
Error: Cannot find module 'C:\Users\sworley\Documents\Udemy\@angular\cli\bin\ng.js'
at Module._load (node:internal/modules/cjs/loader:841:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47 {
code: 'MODULE_NOT_FOUND',
}
My path is set to look for angular and capacitor in C:\Users\sworley\AppData\Roaming\npm\node_modules@angular\cli\bin and C:\Users\sworley\AppData\Roaming\npm\node_modules@capacitor\cli\bin respectively, so I do not understand why the build is looking for them in these local folders or how to remedy this.
I hope this is detailed enough, let me know if there is any more info I can provide.
A reboot appears to have fixed the issue and allowed the new path variables to be picked up by ionic. I still get this message on ionic build
and ionic serve
but it works.
[ng] 'Web' is not recognized as an internal or external command,
[ng] operable program or batch file.
[ng] 'Angular\ia-proj\node_modules\.bin\' is not recognized as an internal or external command,
[ng] operable program or batch file.
I’ll check with the rest of my team to see if they know whats up, as I’m on a mac, so I haven’t tested in powershell
Thank you, however I have resolved the issue. The problem was that the computer needed to be rebooted, and the folder name at the top most level could not have spaces in it. I appreciate the response.