First of all, I recommend resolving npm permissions, so that you can avoid using sudo when installing npm modules. Check this video, there are several options mentioned in it. Here is what worked for me:
$ whoami
tom
$ sudo chown -R tom /usr/local/lib/node_modules
$ sudo chown -R tom /usr/local/bin
$ sudo chown -R tom /usr/local/share
$ npm config set prefix /Users/tom/npm-global
Note that the last command will fail if you happen to have the prefix already set. If that's the case remove the existing prefix by running:
$ npm --prefix="" set prefix ""
Don't forget to update the PATH variable, in ~/.bash_profile:
export PATH="/Users/tom/npm-global/bin:${PATH}"
Finally, ensure that you are the owner of ~/.npm directory.
$ sudo chown -R tom ~/.npm
Strange as it sounds, some of the content in that directory was in my case owned by root. That caused issues later on and my project couldn't be generated without errors.
Restart your terminal and you are good to go.
#1 Java
$ java -version
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
#2 Maven
$ mvn -version
Apache Maven 3.2.5
#3 Git
$ git --version
git version 1.9.3 (Apple Git-50)
#4 Node.js + npm
$ node -v
v0.12.2
$ npm -v
2.7.4
#5 Yeoman
$ yo --version
1.4.6
#6 Bower
$ bower --version
1.4.1
#7 Grunt CLI
$ grunt --version
grunt-cli v0.1.13
#8 JHipster Generator
$ npm list -g --depth=0 | grep jhipster
├── generator-jhipster@2.7.0
In the next step, create an application directory and start the generator. My sample app is called simply myapp:
$ mkdir myapp && cd $_ && yo jhipster
Provide the required information. I opted for MongoDB and stateless authentication as I wanted to have an app which would scale well:
Now just wait until the generator completes. Beware it may take quite some time. Pay attention to errors and resolve them individually. An awful lot of files is being downloaded and you need a solid network connection. Even then though, some of the dependencies can (and will!) fail to download.
Hopefully, at some point, you get to see a successful build:
In your project directory run grunt and then start the app by running mvn spring-boot:run
Now comes the confusing part. Initially, the app loaded as expected. Seeing the fully functioning UI is a very rewarding experience and I find the features impressive.
On the other hand, it all feels rather fragile. For instance, the app was successfully started the very first time. Upon subsequent restarts, and I swear I hadn't changed a single line of code (!), I started to see errors. Typically, AngularJS wouldn't load or there were failing modules etc. I tried rebuilding the project, but that didn't help. All in all, the UI breaks very easily and it's not too obvious what exactly went wrong.
I haven't given up just yet and continue experimenting. I will post an update if I manage to solve the remaining issues. Stay tuned.
Thanks for linking to my blog post! I haven't had so much trouble with failing modules, I wonder what's happening at your end.
ReplyDeleteIf you run into issues, you might consider posting an issue on the JHipster GitHub. It's pretty active and bug fixes can come pretty quickly. I try to contribute a little bit lately as well.
Thanks, I hope I've missed something obvious. I will try again when I find a spare minute.. Cheers.
ReplyDelete