Forums de discussion

Help with Dev Setup for Liferay 7 Themes

thumbnail
Andrew Jardine, modifié il y a 6 années.

Help with Dev Setup for Liferay 7 Themes

Liferay Legend Publications: 2416 Date d'inscription: 22/12/10 Publications récentes
I have to keep reminding myself to breathe -- to say that I have had a frustrating experience trying to follow the docs, and the 400 billion posts on the web for how to get all these JS tools to work would be the understatement of the year. Here is what I have.

+ I am using Linux. Yes, LINUX. Not MACOSX. Ubuntu 14.04 LTS
+ I have remove all references to node from my machine to start with a clean slate.
+ I tried to follow these steps -- https://dev.liferay.com/develop/tutorials/-/knowledge_base/7-0/themes-generator -- didn't work.
+ I did some digging and people seem to agree that because there are 50 different versions of Node, the use of NVM is the best option.
+ Ok -- so I did this -> http://www.hostingadvice.com/how-to/install-nodejs-ubuntu-14-04/ (option #1)
+ All of that seems to work -- so I went back to the knowledge base referenced above to RUNNING THE LIFERAY THEME GENERATOR
+ I was prompted for Steps 1 - 4, but not the last 2.
+ After step 4 I see this --

npm WARN package.json sample-liferay7-theme@1.0.0 No description
npm WARN package.json sample-liferay7-theme@1.0.0 No repository field.
npm WARN package.json sample-liferay7-theme@1.0.0 No README data
npm WARN package.json sample-liferay7-theme@1.0.0 No license field.
npm ERR! registry error parsing json
npm ERR! Linux 3.13.0-53-generic
npm ERR! argv "/home/aj/.nvm/versions/node/v4.2.2/bin/node" "/home/aj/.nvm/versions/node/v4.2.2/bin/npm" "i" "--save" "gulp-ruby-sass"
npm ERR! node v4.2.2
npm ERR! npm  v2.14.7


and then the entire contents of the script file for hundreds of lines. Just to rant for a second, what a moronic way to handle an error -- dump the whole application source to the terminal.

Anyway, so here i am stuck. I can run npm install -g and that doesn't throw and error but doesn't appear to do anything either. When I try to do the gulp build command I get

Error: Cannot find module 'liferay-theme-tasks'
    at Function.Module._resolveFilename (module.js:337:15)
    at Function.Module._load (module.js:287:25)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)


when I try to do npm install -g liferay-theme-tasks I get that lovely dump of the application script with the ERR! on every line. I'm not a JS developer. If anyone has any suggestions, I am happy to be a guinea pig.
thumbnail
Christoph Rabel, modifié il y a 6 années.

RE: Help with Dev Setup for Liferay 7 Themes

Liferay Legend Publications: 1554 Date d'inscription: 24/09/09 Publications récentes
Umm, I am on 14.04 too (at home). I was to lazy to upgrade so far since everything works and ...

But I have the following versions installed:
node -v
v7.2.1
npm -v
3.10.10

I think, I just did an
apt-get install nodejs npm (Option 2 in your link)

With nvm you should be able to install current versions of node too. v4.2.2 is probably to old. Or scrap it and install using apt-get.
thumbnail
Andrew Jardine, modifié il y a 6 années.

RE: Help with Dev Setup for Liferay 7 Themes

Liferay Legend Publications: 2416 Date d'inscription: 22/12/10 Publications récentes
Hey Christoph,

Fighting with this yesterday I had, before I started, nodejs installed -- which I had done previously with apt-get. I installed NVM because everything I read said that was the best option because, apparently, it is not uncommon to come into situations were you need one version of node for one thing, and a different version for something else. I was able with nvm to install it, but nvm is not globally accessible of course.

So then I had a whole other issue in that when I ran npm as my user I got the same error I referenced above. Running npm as sudo got me past the "socket error" (for a comment on the npm site where someone said that was how they got around it) but it didn't get me all the way because running npm as root used (I guess?) the global version that was 0.10.27 or something.

I'll try installing using the second step - but this is really annoying. I was trying to follow the guide that specifically calls out 4.2.2.
thumbnail
Andrew Jardine, modifié il y a 6 années.

RE: Help with Dev Setup for Liferay 7 Themes

Liferay Legend Publications: 2416 Date d'inscription: 22/12/10 Publications récentes
Ok -- so I removed all references to nvm, though I am sure I will be back to it in a moment.

I ran the steps for the second option in the link. Still doesn't work. My guess is that the versions in repo are too old? I am getting

$>node -v
v0.10.25
$>npm -v
3.8.8


.. node installed globally

$>which node
/usr/bin/node


.. but npm is not (I just ran the command the article said to run).

$>which npm
/home/aj/.npm-packages/bin/npm


.. so when I try to run npm install I get the an error parsing json (this is all stock theme right now, I haven't changed anything). If I try to run npm install -g, I get a permissions error because my user can't access /usr/lib. But if I try to run it as sudo, it won't work because npm is installed under my user. sigh.

Maybe option 4 is the best? I can set my own global locations and pick my version? It'd just be nice to know which versions I have to install to know for sure that everything will generate, build and deploy properly.
thumbnail
Christoph Rabel, modifié il y a 6 années.

RE: Help with Dev Setup for Liferay 7 Themes

Liferay Legend Publications: 1554 Date d'inscription: 24/09/09 Publications récentes
Are y

>node -v
v0.10.25

Are you sure you didn't type "nodejs -v" here?

npm -v
3.8.8

Hmm. Why do I have 3.10.10 here and you 3.8.8.
You could try npm update (maybe with sudo)

Btw.:
which npm
/usr/local/bin/npm


 which node
/usr/local/bin/node


Well, I think this is better discussed in chat. But it is quite late here. Maybe monday, if you still have issues then.
thumbnail
Andrew Jardine, modifié il y a 6 années.

RE: Help with Dev Setup for Liferay 7 Themes

Liferay Legend Publications: 2416 Date d'inscription: 22/12/10 Publications récentes
Positive it wasn't nodejs. The day is done for me as well. Thanks for trying to help. Perhaps if I get a chance over the weekend I should read a little more about node and npm so that I can understand better how all of this is supposed to be working. If I am still struggling on Monday -- i'll see if you are around and have a few minutes on Slack.

Thanks Christoph.
thumbnail
Christoph Rabel, modifié il y a 6 années.

RE: Help with Dev Setup for Liferay 7 Themes

Liferay Legend Publications: 1554 Date d'inscription: 24/09/09 Publications récentes
Well, the guide doesn't tell you to actually install 4.2.2, it just says that it was the version at the time of this writing. That's a diffference. :-)
I guess that Liferay folks also upgrade npm frequently.

That 0.10.27 version number is completely misleading.

> dpkg -l | grep nodejs
nodejs 0.10.25~dfsg2-2ubuntu1

> node -v
v7.2.1
thumbnail
Andrew Jardine, modifié il y a 6 années.

RE: Help with Dev Setup for Liferay 7 Themes

Liferay Legend Publications: 2416 Date d'inscription: 22/12/10 Publications récentes
I supposed we would have to agree to disagree on this one. This is a whole new method to building themes with a whole new set of tools that are probably unfamiliar to a lot of people who have been with Liferay for several versions now. If the 4.2.2 is not a requirement then I would omit it from the description altogether. ANYWAY, I've now undone step #2 and done step #4 ... so I have both installed, and they're newer than your versions which means they should be ok right? or at least ,my npm matches "at the time of this writing" emoticon

$>node -v
4.2.2
$>npm -v 
2.15.1


.. but, NNNNNNNNNNNNOPE!

$> npm install
npm WARN package.json sample-liferay7-theme@1.0.0 No description
npm WARN package.json sample-liferay7-theme@1.0.0 No repository field.
npm WARN package.json sample-liferay7-theme@1.0.0 No README data
npm WARN package.json sample-liferay7-theme@1.0.0 No license field.
npm ERR! registry error parsing json
npm ERR! registry error parsing json
npm ERR! registry error parsing json
npm ERR! Linux 3.13.0-53-generic
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v4.4.4
npm ERR! npm  v2.15.1

npm ERR! Unexpected token <
npm ERR! 


.. I'm totally lost. Obviously I am doing something wrong here. This can't possibly be the hardest part of Liferay 7. It is making me long for the good 'ol days though.
thumbnail
Christoph Rabel, modifié il y a 6 années.

RE: Help with Dev Setup for Liferay 7 Themes

Liferay Legend Publications: 1554 Date d'inscription: 24/09/09 Publications récentes
Yes, the documentation is misleading. It probably just worked for me because I ignored the version and just installed the default for the OS. We had a lot of issues with a year ago when we did our first baby steps with Liferay 7. Luckily there was this guy in the other room who uses gulp and node for years now and who explained a lot of things to us.


Now you are back again to version 4.2.2. I think you are still using that old version, maybe from nvm.
My suggestion:
Get rid of npm, node, nvm, everything. Clean slate.

nvm uninstall <version>
If you installed something with apt-get, purge it.
sudo apt-get purpge npm nodejs

Delete the .npm folder docu mentions. It just allows you to update some stuff without sudo.
All gone?

Now install them with
sudo apt-get install nodejs npm
thumbnail
Andrew Jardine, modifié il y a 6 années.

RE: Help with Dev Setup for Liferay 7 Themes

Liferay Legend Publications: 2416 Date d'inscription: 22/12/10 Publications récentes
ok -- problem solved, but what a nightmare to get there. Here is what I had to do incase someone else comes along with this same issue.

MY ENVIRONMENT
+ Ubuntu 14.04 LTS
+ I have both apt-get and aptitude installed

The first thing I did was scrub everything (as Christoph suggested). I did the apt-get remove --purge for npm and node. I went through the .bash_profile, .profile and .bashrc to remove any system variables. I deleted all references to .npm-packages and .npmrc to make sure that everything node and npm were gone. I also double checked that all my efforts to remove nvm from my system were done as well. Once all of this was done I heck in several locations, ran find and try a few command line instructions to see if any reference to node, nodejs or npm could be found. At this stage I was satisfied that I had scrubbed it all off the deck.

Before going on to the next step I thought perhaps educating myself a little on node and npm was the right way to go so that I didn't just blindly follow blog posts and message forums. I recently started using Arch Linux on my desktop and the wiki pages for Arch are pretty awesome, so I started (and ended) there. It wasn't a long read but I finally understood (though I dislike the model) of how it works. For those who don't know and want the coles notes:

1. Packages can be either local (in the current directly) or global
2. Global packages are SYSTEM WIDE if you don't have a user prefix setup
3. If you have a user prefix set them you still use the global flag, but they are global to your USER only (this is what I think is dumb -- but that's for another debate)

.. so I wanted to do this as per the norm. The consensus seemed to be that user global was the best option because then you don't have to worry about permissions and such. I installed node and npm from the universe repos but the versions were old. so I later removed them again and did this to get the 4.x branch of node.

$&gt;curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -


.. which basically added a new source. Then I did --

$&gt;sudo apt-get install nodejs


.. and to install npm and avoid errors about dependencies and blah blah blah I did

$&gt;sudo aptitude install npm


At this stage I did the node -v and npm -v and found the results to be

aj@tank:~$ node -v
v4.8.3
aj@tank:~$ npm -v
2.15.11


Sweet. problem solved right? NOPE! I still got this silly ERRCONNREFUSED error and the really weird thing is that it was trying to connect to localhost 8080 or 127.0.0.1 8080. I have no proxy configured. So I started trying to figure that one out (with Christoph's help). Nothing in proxy settings, My route -n command showed no internal hops, so weird. Some people said you just need to remove the proxy config for npm with this --

$&gt;npm config rm proxy
$&gt;npm config rm https-proxy


.. but for me anyway there was more to be done. I had to do those two commands, yes, but then I also had to run these --

$&gt;unset HTTP_PROXY
$&gt;unset HTTPS_PROXY
$&gt;unset http_proxy
$&gt;unset http_proxy


with this in place I went back to my theme project and ran

$&gt;npm install -g generator-liferay-theme


THat worked. I had to install a couple of other packages (globally) using the npm command but eventually I was able to run

$&gt;gulp build



... and have successful output. No more 127 or localhost references stoped and I was able to resolve npm packages and installed.

It was a nightmare to get through so hopefully anyone else that comes along will find some help in this post. Anyway, for now I think I'm good to go. Thanks (mostly to Christoph) for helping out.
thumbnail
Christoph Rabel, modifié il y a 6 années.

RE: Help with Dev Setup for Liferay 7 Themes

Liferay Legend Publications: 1554 Date d'inscription: 24/09/09 Publications récentes
unset only removes the exported variable from the current shell. You probably still have the proxy set somewhere. You should take a look into ~/.bashrc and /etc/bashrc. There might be other places too, but these are the hottest candidates.

Anyway, glad you managed it. emoticon
thumbnail
Andrew Jardine, modifié il y a 6 années.

RE: Help with Dev Setup for Liferay 7 Themes

Liferay Legend Publications: 2416 Date d'inscription: 22/12/10 Publications récentes
That's what I thought as well so I went on the hunt for it but no matter where I searched I could not find a reference to it. I even tried starting a new terminal (where the unset commands were not yet run) to see if I could echo the variables out.. but I get a "blank" (empty line) for each of them.

So for the time being, as I have wasted enough time on just getting this set up as it is, I've opted for adding those lines to my bash profile so that when I open a new terminal I know they are run and I don't have to worry about remembering them later. It's a dirty solution, but sometimes you gotta be willing to get a little dirty to push forward.

Now -- onto the juniper vpn emoticon
thumbnail
Christoph Rabel, modifié il y a 6 années.

RE: Help with Dev Setup for Liferay 7 Themes

Liferay Legend Publications: 1554 Date d'inscription: 24/09/09 Publications récentes
Ok, I have to correct myself here:
While I did indeed install the OS version, I later used a tool called n (yes, one letter) to install a higher version of node. Probably I did a
sudo n stable
and then forgot it later.