Missing modules after generation using Yeoman'

2019-08-09 23:55发布

问题:

There's a question with almost the same title as mine with no answers here, and I can't comment to see if @Gabriel-Kunkel got anywhere with it. I was going to post an answer, but I saw StackOverflow said to avoid doing that, so asking the same question was the best I could think to do...

I'm trying to get a fresh install from the generator-angular-fullstack with these options

  1. Grunt
  2. Jasmine
  3. TypeScript
  4. HTML
  5. LESS
  6. ui-router
  7. Bootstrap
  8. UI-Bootstrap
  9. Mongo
  10. Authentication Boilerplate (Yes)
  11. No other oAuth strategies
  12. Socket.io (Yes)

The generator, before changing/adding anything, loads a blank screen with these error holding it up in the Chrome console:

Uncaught Error: [$injector:nomod] Module 'intranetApp.auth' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.

And also the same thing with 'intranetApp.admin'

Does anyone know what I can do to fix this?

回答1:

TL;DR

Inside your Gruntfile.js, you need to replace var module = /\.module\.js$/; with var module = /[\w/]+.module.ts$/; (Line 632 as of commit#24f1fc1 of the generator)

/TL;DR

So this took a while and brought me to quite a few pages, but I'll try my best to give credit where it's due.

First, I noticed from an identical question to mine, @gabriel-kunkel pointed out there were some missing peer dependencies which I installed (not sure if you should add --save or --save-dev to these commands, but I used --save-dev):

  1. npm install tslint
  2. npm install kerberos
  3. npm install typescript

You may have others though, so look in your console output at the bottom of the dependency tree.

Second, I saw I got an error regarding xcode-select when running npm install and to fix that, I found here that I needed to install xcode from the Apple App Store. I installed the latest non-beta version at the time, which was v7.2.1 and then entered sudo xcode-select -s /Applications/Xcode.app/Contents/Developer into the console (as the link says, your path may be different - mine wasn't).

Third and lastly, I stumbled here which stated exactly what I needed to do to fix my problem. Gruntfile.js needed one line to be changed... a quote from fdfandrade from that link:

Replacing this "var module = /.module.js$/;" by this "var module = /[\w/]+.module.ts$/;" in my Gruntfile.js worked for me!

For me, it was line 632. Hope this helps someone else from going insane trying to figure this out.