Showing posts with label macOS. Show all posts
Showing posts with label macOS. Show all posts

Sunday, September 18, 2016

Why I Just Bought a MacBook Pro

I wrote a post in 2014 entitled, Why I Just Bought a Chromebook, so it may seem odd that I'm now writing this post. To be clear, I'm not backing off my favourable position on Chromebooks at all. They're great and they can be a lot more affordable than other laptops... like the MacBook Pro, for example. MacBooks are overpriced; I feel that's a pretty defensible comment. So why would I buy one?


The answer is actually quite simple and surprisingly non-technical. I have spent my entire career working in software, but I've never bought an Apple computer of any type. I've been using my wife's old MacBook for years, but I've never experienced the best that Apple has to offer and I always wondered what I was missing. If you combine that with the current popularity of Macs--especially amongst web developers--and I just decided it was time. I've run many versions of Windows. I've used FreeBSD and some flavours of Linux (including Ubuntu on my Chromebook), but it's not until now that I can say that I've really had the full Mac experience.


Unfortunately, this version of the MacBook is missing some of the hardware niceties that I enjoyed in the older MacBook I used. For example, the MagSafe connector for the power cord is gone, there is no SD card reader, no light to show the battery is charging, and no external lights to show how much of the battery remains. Those were all useful. Most people have heard about the lack of ports on this new laptop--I've given a nod to that controversy by including a dongle in the image above. Almost everything requires a dongle which is a pain. One notable exception is the headphone jack. Until the iPhone 7, the MacBook Pro actually does have a headphone jack which is nice. I'll have to see how much of an issue this is (or isn't) for me. So far, I've only purchased one dongle--for USB devices. That will cover a lot for me. If I really have issues, I'll get one of the third-party adaptors that adds ports to the machine. (Update: I saw a pretty cool "HyperDrive" one that adds an SD card reader, USB port and HDMI port.)

Of course, there are lots of improvements as well. The screen is much better, the battery life is improved and everything just generally runs faster on the newer processor and RAM. I also really like the keyboard. It has a very satisfying click which reminds me of a mechanical keyboard.

I haven't had the machine very long, so this isn't a proper review. At this point, I'm feeling good about the purchase. Yes, I do miss some MacBook features, but the Pro machine is much faster than my old one and allows me to project to Apple TV. The other one was too old to offer that feature--which gives you an idea of just how big a step us this was in hardware. 

Sunday, August 14, 2016

Angular 2 ng serve or ng build Permissions Error

Update: If you're running macOS, you should just use Homebrew from the start and you'll likely avoid these issues.

If you grab an Angular 2 project from the web, you might find that you run into permissions errors after you install it.

For example, these commands are a common example of a simple project install. (This example uses yarn, but NPM would have similar results.) The addition of 'sudo' is common on Macs, but it can cause the permissions problem.

$ sudo npm install -g angular-cli
$ sudo npm install -g yarn
$ sudo yarn install

The problem occurs when you try to run $ ng serve (or $ ng build); you see an error such as this one:

EACCES: permission denied, open '/Users/cawood/GitHub/test/node_modules/arr-flatten/index.js'
Error: EACCES: permission denied, open '/Users/cawood/GitHub/test/node_modules/arr-flatten/index.js'
    at Error (native)
    at Object.fs.openSync (fs.js:640:18)
    at Object.fs.readFileSync (fs.js:508:33)
    at Object.Module._extensions..js (module.js:578:20)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object. (/Users/cawood/GitHub/mix/node_modules/arr-diff/index.js:10:15) 
...  

The error occurs because the install ran as the admin user. The quick solution is to give the current user sufficient rights to the folder structure in your project. This example is heavy-handed, but it's fine for prototypes. These commands change the permissions recursively for everything (files and folders) in the test directory which is the one that contains the Angular 2 project.

$ sudo chmod -R +rwx test 
$ cd test 
$ ng serve