Installing Node on my Chromebook
In a previous post, I discussed some of the challenges that I faced when attempting to set up a development environment on my Chromebook. I had success in that I was able to clone repos from Github, make changes, and then upload the updated code back to Github. For me, this was no small feat, as I was seeing many of the concepts and acronyms for the first time. However, it was immediately clear to me that my work was not done. Like I said, I was able to push and pull my code from remote repositories, but as far as actually developing my projects I was severely limited — I had no ability to run commands such as “npm start” or “node app.js” to see the effects of my changes, nor could I run the familiar command “open exampleFile.html” to at least see my html pages when developing simpler HTML/CSS/JS projects.
For fixing wording of paragraphs, the setup that I had would work just fine, but other than that if unable to actually locally run the apps, I would essentially be going in blind, only able to see the effects of my changes if I made my changes effective for the production branches, which for my purposes might actually work, but would have added additional steps for me, and certainly would not be considered a best practice. I’m sure as I go through more projects, I may need to install other packages or programs, but for now, I’d like to detail what I ended up doing to my poor Chromebook in order to be able to run the command “node app.js” so that I could test out changes to my portfolio site, (which can be located at jacobkenny.com).
Earlier I had mentioned the command “open exampleFile.html” was not working for me. Before I went about anything else, I wanted to at least try to get that working for me. Typically what I would expect when running that command is for the file to open up in my internet browser appearing as it would once deployed. This was a simple fix that just required a little bit of research. Your mileage may vary for this one, but ultimately I found that altering the command to “xdg-open exampleFile.html” yields the desired effect. However this does me no good for something more complicated such as a React or Express.js application.
Typically to run these types of applications locally I’ve run the commands “npm start”, or “node app.js.” Since the application I was most concerned with was my portfolio site built on Express, I really needed the node command to work, however when I entered the command in the terminal I received an error message “-bash: node: command not found”. I tried to think back to those days where I was doing the initial set up of my beloved macbook air for guidance but my memory is not that good. My inclination however, was that if a command that I need to use wasn’t recognized that it must mean that I am missing some software, which should be easy enough to install, and that was certainly the case here — I needed to install Node.
After little bit of research, I determined that it would be best to handle things through a Node version manager. I could have installed the latest version of Node individually, but there are many versions of Node out there, and there’s a the potential to have to switch between them. Doing that manually could be tedious and complex, so most recommend using the version manager. I located my version manager here: https://github.com/nvm-sh/nvm#install--update-script, and then from there I went ahead and installed it on my machine with the following terminal command:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.36.0/install.sh | bash
I was hesitant to do this because these commands are hard for little ol’ me to understand exactly what’s going on, and I’ve worried that I might copy and paste a command posted by someone out to do harm, but this one seemed to work just fine, and also came from a site that I believe is a reputable source. I haven’t had any problems yet, so I’m hoping that trend continues in the future!
With my Node version manager ready to go, there was only one thing left to do: install Node. I entered the terminal command that I hoped would complete the final stage of the installation process, “nvm install node,” hopped over to my projects, and crossed my fingers. Surprisingly, when I ran the command “node app.js” I got another error message. I don’t have the message saved, but it was an error due to something with Express.js. I began to troubleshoot like I was once told not to do — entering random terminal commands. I thought that “npm install” would be a good place to start, and thankfully once that completed I was able to successfully start up my application.
I have a feeling there will be little things like this that will continue to arise as I work on more projects with different technologies, but at least for now, things seem to be working as they should be. If all the sudden the commands I entered begin to backfire and things stop working, I’m pretty sure that I haven’t done anything that can’t be undone; I can always do a factory reset.