Picture of Steve Baker
Mac Grunt/Gitbash/Node.js confusion...
by Steve Baker - Tuesday, 29 March 2016, 11:08 PM
 

Hi there

First post here. 

Have just taken on my first freelance Adapt project outside of Kineo (Hi Kineo people!) and having never setup the dev environment a) on a Mac and b) outside of Kineo, I'm rather confused about what I need to do and how.

I should first say that it's an existing build that I'm helping to finish, not a build from scratch. 

I've downloaded and saved the project folder onto my machine. The issue I'm having is simply navigating to that folder and being able to run the Grunt tasks (this is pre-rub) to compile from src to build. Usually done using GitBash by right clicking and using 'GitBash here'. 

So it's potentially a very simple problem. I don't have much time to read through the hundreds of other posts but have read some and am still confused. 

I've installed Git, Node.js. 

I've run 'npm install adapt-cli -g' and 'npm install grunt-cli -g' (prefixed with 'sudo')

What now? 

Appreciate any help and/or instructions. 

Picture of Matt Leathes
Re: Mac Grunt/Gitbash/Node.js confusion...
by Matt Leathes - Thursday, 31 March 2016, 11:04 AM
 

Hi Steve

Have you read everything on this wiki page? The link 'just enough command line for installing' sounds like it might be quite helpful.

If you have read all of that, which particular bit are you struggling with?

Picture of Steve Baker
Re: Mac Grunt/Gitbash/Node.js confusion...
by Steve Baker - Friday, 1 April 2016, 8:29 AM
 

Hi Matt, 

Thanks for replying. 

I did read that page but have just re-read through to make sure. I tried setting this up on my Windows laptop last night but when I tried to extract the zip of the project I'm working on, it failed to extract as it said the file was invalid - which is strange because I already unzipped it once on my iMac - so I couldn't go through the process fully. Looks like I'll have to do the work on iMac. 

So, the issue I was having problems with was the bit where, in Windows you right-click and 'Gitbash here' to open the console/terminal and run the grunt commands. Without much tech know-how regarding this, I couldn't find how to do this without GitBash (which I don't think is available for Mac). 

Tom Greenfield mentioned that I need to navigate to 'Services > New Terminal Tab at Folder' - but I haven't yet tried that - will do this evening or tomorrow. 

Obviously since this is an existing build, I don't need to run 'grunt build' but I will be working within 'src' (it's not the latest Adapt) so need the commands like 'watch' and/or 'dev' to compile into the build. 

Cheers, Steve

Picture of Matt Leathes
Re: Mac Grunt/Gitbash/Node.js confusion...
by Matt Leathes - Friday, 1 April 2016, 9:11 AM
 

Hi Steve

The wiki page 'just enough command line for installing' contains a basic guide to navigating around your hard disk using Terminal. Tom's suggestion is a very good one though, I have to say I didn't know about that.

You should always do $ grunt build before delivering final version of a course (the one the client's actually going to go live with) as this 'minifies' all the JavaScript and removes all sourcemaps. It's also always worth doing a 'tracking-reset' to ensure the tracking ids are all present and synchronous (note that you should never do this if you're updating a course that is already in use).

Picture of Steve Baker
Re: Mac Grunt/Gitbash/Node.js confusion...
by Steve Baker - Friday, 1 April 2016, 9:55 AM
 

OK that's good to know, thanks! 

I've been advised to try unzipping with 7 Zip so if that works, I'll be able to use Windows/GitBash - but I'll make sure to read all of that wiki page. 

Thanks again

Steve

Picture of Steve Baker
Re: Mac Grunt/Gitbash/Node.js confusion...
by Steve Baker - Saturday, 2 April 2016, 10:54 AM
 

this is tripping me up at the moment...  :-/ 

Never have I felt like such a rookie!


Picture of Steve Baker
Re: Mac Grunt/Gitbash/Node.js confusion...
by Steve Baker - Saturday, 2 April 2016, 2:37 PM
 

Bad to worse!

 

This one is a real puzzler and has meant I can't do the work. 

Can't believe how many problems I've had just getting this up and running! 

Appreciate any help. 

 


Picture of Matt Leathes
Re: Mac Grunt/Gitbash/Node.js confusion...
by Matt Leathes - Saturday, 2 April 2016, 4:40 PM
 

Searching for the error 'cannot find module npmlog' would seem to indicate you might have a buggy/knackered version of node installed.

Also, node itself develops at quite a rapid pace - too fast for us to be able to ensure that Adapt is compatible with every single version.

I have 0.10.35 and 4.3.1 installed. Looks like 4.3.1 works fine with Adapt v2.0.8; I think you might need an earlier version like 0.10.35 for older versions of Adapt. Give both a try

You might be better off uninstalling Node completely and instead using Node Version Manager for Windows. This will allow you to easily install specific versions of Node and switch between them. Just remember that you have to install things like grunt-cli for each version of node. So if you install grunt-cli under 4.3.1 but then switch to 0.10.35 you'll have to install it again.

Alternatively you know Kineo's 'rub' build tool is set up to work with Adapt Open Source? You could just use that instead.

Picture of Steve Baker
Re: Mac Grunt/Gitbash/Node.js confusion...
by Steve Baker - Sunday, 3 April 2016, 1:05 PM
 

OK thanks. I'll give that a go. The project I'm working on has the node_modules folder already there so do I need to delete that folder? Or just uninstall Node.js?

 

Picture of Steve Baker
Re: Mac Grunt/Gitbash/Node.js confusion...
by Steve Baker - Sunday, 3 April 2016, 3:03 PM
 

- OK so I've installed 4.3.1 and run the commands 'npm install grunt-cli -g' and npm install adapt-cli -g' - when I run any grunt commands like grunt server for example, I just get the error message 'Local Npm module "grunt-cli" not found. Is it installed?' - I have run 'grunt' and got the same message followed by the running of some tasks - "less:dist", "handlebars:compile" and it's running 'watch'. When I make a change to components.json in the src, the grunt task over-writes src and reverts the amend instead of pushing the amend to build. I don't know what's going on there!

I'm not quite suicidal yet but getting close. 

Picture of Matt Leathes
Re: Mac Grunt/Gitbash/Node.js confusion...
by Matt Leathes - Sunday, 3 April 2016, 5:16 PM
 

So, when you were sent the zip of this course, did it include node_modules?

If so that may be at the root of many of the problems you're having, those files are specific to the computer and project and shouldn't be sent to anyone else (just trying to zip/unzip a zip file containing these is a nightmare for a start). You also shouldn't ever add them to version control.

I would delete this folder and run $ npm install again to regenerate it.

You'll find it quickest to delete using the command line via rmdir /s/q node_modules

"I'm not quite suicidal yet but getting close" - excellent, that means you've reached the sweet spot of modern web development ;-)

Picture of Steve Baker
Re: Mac Grunt/Gitbash/Node.js confusion...
by Steve Baker - Tuesday, 5 April 2016, 8:57 AM
 

Hi

Yes, that is the case but deleting it a re-installing hasn't worked. Laura Haselum kindly popped round to have a look and wasn't able to work out what was going on with it but after trying to get grunt tasks like 'server' to work on both my Windows laptop and iMac, the same issue happens with the same error message relating to the local install of grunt-cli not being installed, despite being in the node_modules folder. 

I've come to the conclusion that there must be something inherent within the project structure (which is really weird all round) that is causing this. I'm hoping to be having a chat this morning with Stuart O'hare who I think was involved in the build. 

It's a really harsh entry into the world of non-Kineo Adapt freelance work. Hoping future projects are more straight-forward. This one is for a company who aren't following the rules of the platform it seems. 

Thanks again for all your help! 

Steve

Picture of Stephen Bates
Re: Mac Grunt/Gitbash/Node.js confusion...
by Stephen Bates - Monday, 4 April 2016, 6:20 PM
 

I'm actually in the same boat as i'm switching to a MacBook after having a windows laptop at work for the past year+. I'm a little fuzzy as to where i'm installing adapt and grunt. My folder structure is like this:

 

$Sbates

Adapt

production-templates.

 

I've tried running sudo npm etc etc for them both in all three folders, and when i drill down further into folders for each 'template' i use, if i try to then run grunt server-scorm, it tells me 'fatal error: unable to find local grunt'. Is there a way to globally install adapt and grunt, or do I literally have to go into every single folder and install both?

 

(this was way easier on a PC.....*sigh*)

Picture of Sam Tsiu
Re: Mac Grunt/Gitbash/Node.js confusion...
by Sam Tsiu - Tuesday, 5 April 2016, 2:19 AM
 

Hi Stephen

To install grunt-cli and adapt-cli globally, you run:

npm install -g grunt-cli adapt-cli

The error indicates that you haven't have grunt installed for the project. Have you run npm install in the project root?

 

Cheers

Sam

Picture of Stephen Bates
Re: Mac Grunt/Gitbash/Node.js confusion...
by Stephen Bates - Thursday, 7 April 2016, 9:47 PM
 

Thanks Sam. I ran 'sudo npm install -g grunt-cli adapt-cli', in my root adapt folder and got the same result when i navigated to a course an ran grunt server-scorm:

"Fatal error: Unable to find local grunt."

in addition, it looks like the installation of either grunt or adapt itself was not running properly:

 

Picture of Sam Tsiu
Re: Mac Grunt/Gitbash/Node.js confusion...
by Sam Tsiu - Friday, 8 April 2016, 2:14 AM
 

Hi Stephen

The error says you don't have grunt installed as a project dependency. 

Have you run the npm install command to install the dependencies in your project root directory? 

Can you find a node_modules directory in your project root directory?

the npm install command will install all the project dependencies into the node_modules directory. If you don't have them installed or somehow the previous install was broken, try remove the node_modules directory from your project root and run npm install command.

please let me know if this is of help.

Sam

Picture of Stephen Bates
Re: Mac Grunt/Gitbash/Node.js confusion...
by Stephen Bates - Friday, 8 April 2016, 5:31 PM
 

Looks like running npm install somewhere worked, or else I was doing something wrong before, because if I drill down into a course folder and run all the grunt commands, so I think i'm good. Thanks for your help Sam!

Picture of Sam Tsiu
Re: Mac Grunt/Gitbash/Node.js confusion...
by Sam Tsiu - Saturday, 9 April 2016, 1:30 AM
 

I'm glad it is of help.

Cheers

Sam