Node Newbie Error – NPM Refusing to Install Package as a Dependency of Itself

I encountered an error and thought I’d post the solution here since it just might happen to you sometime!  Here’s the scenario:

I was planning to take the winston npm module out for a spin to try out it’s awesome logging capabilities.  I created a directory called winston to create a project and conduct the test.  What would be more logical than that?  🙂

Next, I ran npm init to create a package.json file hitting my Enter key as fast as it could go to accept all the defaults for this throwaway test project:

npm init screencast gif

Continue reading

Solution for Can’t Ping Raspberry Pi Hostname on the Network

In preparing for my upcoming tutorial which is a beginner’s guide to installing Node.js on a Raspberry Pi 2, I ran into an issue. After getting the RasPi is up and running on the network, I was not able to ping its hostname (raspberrypi, by default) from another machine and find it so I could connect to it through Putty, xrdp, VNC, etc.  After all, I wanted to be able to run headless and disconnect the monitor, USB keyboard/mouse, and still connect to it from another machine on my network.

One option was to run ifconfig on the RasPi and take note of the IP address for eth0 (if connected through Ethernet) or wlan0 (if connected through Wi-Fi).  I could then hard code this IP address in the hosts file on the Windows (or other) machine. The problem is that the RasPi retrieves its IP address through DHCP by default from my local router at home, and this IP address is not guaranteed to remain the same.  I could log into my router and note the static IP address range and reconfigure the RasPi to use one of these static IP address rather than DHCP.  However, I am preparing a beginner’s tutorial and not all of my readers want to become Linux TCP/IP networking experts.

I discovered an elegant solution if you are trying to ping and connect to the RasPi from another Windows machine on the same network.  Samba to the rescue! Continue reading

Learning through Making – Getting Started with Node.js

Learning through Making (LTM) logoToday we are kicking off our LTM (Learning through Making) series of tutorials to delve into the amazing world of Node.js.  We’re going to do some fun projects along the way, but we first need to lay a foundation and get Node.js installed.

What is Node.js?

Node.js logoAs described on Wikipedia, “Node.js is an open-source, cross-platform runtime environment for developing server-side Web applications.” Node.js is awesome because it allows us to build a gamut of applications from highly scalable networked applications to console applications.  Node.js uses a single-threaded event loop model to process events in an event queue which helps it process high amounts of I/O.  This differs from say, the Apache web server, which uses a thread for each new connection and can thus not handle so many concurrent connections.  Node.js is based on JavaScript and is further positioning JavaScript as a universal language that every developer should know. Let’s be on a first name basis with “Node.js” and simply call it “Node” from here on out. Continue reading

Launching a Windows Command Prompt in a Folder of Your Choice

Here’s a handy Windows shortcut I use quite frequently for launching a Windows command prompt in a specific folder using Windows Explorer. Thanks to fellow San Diegan Jon Galloway for teaching me this shortcut in one of his Microsoft Virtual Academy classes.

Scenario: You are navigating through Windows Explorer to a folder of interest and realize that you need to drop down into a command prompt to run a specific command in that folder. For example, you want to launch Visual Studio Code from the command prompt using code . in that folder.
Windows Explorer

Continue reading

Learning to Code with CoDrone

I attended the monthly San Diego Hardware Hackers meeting earlier this week with one of my sons.  The presentation was by a local Kickstarter-funded company, Robolink, who is building a device called CoDrone.  The CoDrone (portmanteau of Code and Drone) is geared to help teach kids how to code.  It can be programmed using the Arduino IDE, and can also be morphed into a Rover kit by replacing the propellers with wheels.  Fun stuff!  You will find the lessons plans here if you want to get a deeper view into how it is programmed.  The goal is to teach computer science to kids as young as the fourth grade. Continue reading