I created a new project with the latest angular-cli npm packages 0.0.25 and can't generate a component?
c:\temp\app5>ng generate component comp1
installing component
Cannot read property 'indexOf' of undefined
TypeError: Cannot read property 'indexOf' of undefined
at Class.module.exports.normalizeEntityName (c:\temp\app5\node_modules\angular-cli\addon\ng2\blueprints\component\index.js:19:19)
at Class.Blueprint._normalizeEntityName (c:\temp\app5\node_modules\angular-cli\node_modules\angular-cli\lib\models\blueprint.js:434:24)
at Class.Blueprint.install (c:\temp\app5\node_modules\angular-cli\node_modules\angular-cli\lib\models\blueprint.js:492:8)
at Class.module.exports.Task.extend.run (c:\temp\app5\node_modules\angular-cli\node_modules\angular-cli\lib\tasks\generate-from-blueprint.js:60:49)
at Class.module.exports.Command.extend.run (c:\temp\app5\node_modules\angular-cli\node_modules\angular-cli\lib\commands\generate.js:77:17)
at Class.<anonymous> (c:\temp\app5\node_modules\angular-cli\node_modules\angular-cli\lib\models\command.js:151:17)
at lib$rsvp$$internal$$tryCatch (c:\temp\app5\node_modules\angular-cli\node_modules\angular-cli\node_modules\rsvp\dist\rsvp.js:1036:16)
at lib$rsvp$$internal$$invokeCallback (c:\temp\app5\node_modules\angular-cli\node_modules\angular-cli\node_modules\rsvp\dist\rsvp.js:1048:17)
at c:\temp\app5\node_modules\angular-cli\node_modules\angular-cli\node_modules\rsvp\dist\rsvp.js:331:11
at lib$rsvp$asap$$flush (c:\temp\app5\node_modules\angular-cli\node_modules\angular-cli\node_modules\rsvp\dist\rsvp.js:1198:9)
That is quite problematic! I went to check and on the latest master, I believe the issue is solved.
@Brocco reworked the way components are generated to allow for dynamic paths. I expect this to be fixed on the next release.
For now, my only solution is to use latest master though.
My mistake, I just tried it on the windows cmd prompt and had the same problem on latest master.
@doczoidberg can you please clarify which version of the CLI you're using/
@Brocco 0.0.25
Changing from line 17 of index.js to
if (entityName.indexOf(path.sep) === 0) {
outputPath = path.join(rootPath, entityName.substr(1));
} else if (cwd && cwd.indexOf(rootPath) >= 0) {
outputPath = path.join(cwd, entityName);
} else if (cwd && cwd.indexOf(path.join(this.project.root, 'src')) >= 0
&& entityName.indexOf('app') === 0) {
outputPath = path.join(cwd, entityName);
} else if (cwd && cwd.indexOf(path.join(this.project.root, 'src')) >= 0) {
outputPath = path.join(cwd, 'app', entityName);
}
Is a good workaround for me just now
@markjritchie that will allow you to get by for now, except it will not allow you to utilize the purpose of this feature, which is to generate items into a dynamic path and also allow routes to be based upon a relative path (current working directory)
@Brocco very true, but I thought it might be handy to post for anybody that's stuck waiting for the next release
I've the same problem on a Windows Environment, is this a Windows problem only ? Does it work on a Linux System like Mac ?
@pierreboissinot It's a windows cmd console specific issue. Which is to say, works on linux and windows with gitbash just fine. We'll fix it.
getting the following error when run
$ ng generate component people
module.js:471
throw err;
^
Error: Cannot find module '@ngtools/json-schema'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
ng generate component myComponent
Any one there to help ?
which version? does it work on a clean project?
No it even do not work on a clean project.
Node: 6.10.3
Ionic: 3.2.0
npm 3.10.10
looking forward to hear
On Wed, May 31, 2017 at 5:08 PM, Daniel Zuidinga notifications@github.com
wrote:
which version? does it work on a clean project?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/angular/angular-cli/issues/297#issuecomment-305216970,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABpGCqvOGRKhBzwEzbhQY7KHixBf-pHfks5r_YJ_gaJpZM4HvTbF
.
--
*Qasim Raza * Senior Developer , Monsenso ApS
[image: http://madsfrost.dk/Signature/monsenso.png]
Mobile: +45 8133 4567 <+45%2020%2082%2013%2042>
Skype: [email protected] rehder@monsenso.com
Email: [email protected] rehder@monsenso.com
Website: www.monsenso.com
Address: Rued Langgaards Vej 7 I DK-2300 Copenhagen S I Denmark I CVR
35517391
[image: http://madsfrost.dk/Signature/f.jpg]
https://www.facebook.com/pages/Monsenso/700649343342567 [image:
http://madsfrost.dk/Signature/gplus.jpg]
https://plus.google.com/u/0/113109219855261076673/about [image:
http://madsfrost.dk/Signature/tw.jpg] https://twitter.com/monsenso [image:
http://madsfrost.dk/Signature/in.jpg]
https://www.linkedin.com/company/monsenso [image:
http://madsfrost.dk/Signature/pin.jpg] https://www.pinterest.com/monsenso/
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._
Most helpful comment
@Brocco very true, but I thought it might be handy to post for anybody that's stuck waiting for the next release