Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript npm Basics (retiring) Installing Packages with npm Managing Dependencies in the package.json File

npm Basics > Installing Packages with npm > Managing Dependencies in the package.json File

Andrew Chalkley:

At 4:56 in the video, I got this code in the terminal:

treehouse:~/workspace$ npm install colors --save

bcrypt@0.8.7 install /home/treehouse/workspace/node_modules/bcrypt
node-gyp rebuild

make: Entering directory /home/treehouse/workspace/node_modules/bcrypt/build' CXX(target) Release/obj.target/bcrypt_lib/src/blowfish.o CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt.o CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt_node.o g++: internal compiler error: Killed (program cc1plus) Please submit a full bug report, with preprocessed source if appropriate. See <http://bugzilla.redhat.com/bugzilla> for instructions. make: *** [Release/obj.target/bcrypt_lib/src/bcrypt_node.o] Error 4 make: Leaving directory/home/treehouse/workspace/node_modules/bcrypt/build'
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/nodejs-binary-6.2.2/lib/node_modules/npm/node_modules/nod e-gyp/lib/build.js:276:23)
gyp ERR! stack at emitTwo (events.js:106:13)
gyp ERR! stack at ChildProcess.emit (events.js:191:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:204:12)
gyp ERR! System Linux 4.4.26-1.el7.elrepo.x86_64
gyp ERR! command "/usr/local/nodejs-binary-6.2.2/bin/node" "/usr/local/nodejs-binary-6.2.2/lib/node_modules/npm /node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/treehouse/workspace/node_modules/bcrypt
gyp ERR! node -v v6.2.2
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok
hash_generator@0.0.1 /home/treehouse/workspace
ā””ā”€ā”€ colors@1.1.2

The "colors" dependency didn't appear in my package.json underneath "bcrypt@0.8.7".

What went wrong? This "bcrypt" version is more current than what appears in the video ("bcrypt@0.8.3"). Did I miss something in a previous video with the Python version that Workspace is now functioning with?

Dan Kelley
Dan Kelley
8,759 Points

Try sudo npm install colors

I think if you want it to be a dependency in your package.json file you would need to install it as follows:

 sudo npm install colors --save-dev

I could be wrong though.

2 Answers

Dan Kelley & Andrew Chalkley:

Using "sudo" & "--sav-dev wasn't in the lesson. The "bcrypt" is a dependency in the package.json but not a development dependency in the package.json.

In the video, when the instructor types & enters "npm install bcrypt", he gets an error message telling him to use a Python version between 2.5.0 & 3.0.0. Then when typing & entering"python --version", the terminal returns "python 3.4.1" in the instructor's video. I get "python 3.5.0". In the video, the instructor then types & enters "python2 --version" & the terminal returns "python 2.7.5". This is where I didn't know what to do since both "bcrypt" & the Workspace Python version have been updated to more current versions since this video was created. At this point, my code created the above error messages. The bcrypt@0.8.3 version has been updated to bcrypt@0.8.7 version. I'm not familiar enough with Git or GitHub to know how report the error or bug as it's printed above. Ubuntu Linux is new to me.

Jeremy Castanza
Jeremy Castanza
12,081 Points

Kathryn, the sudo command is basically a privilege escalation in Linux. It stands for superuser. More than likely, the need to use sudo was due to a Treehouse Workspace security configuration. Personally, I'd try to get away from Treehouse Workspaces, if you can. The upside of using something outside of Workspaces is that you could probably get away without not having to use sudo, depending upon how your coding environment is configured.

While Workspaces are useful for quick learning, it's not practical. If you decide to purse a career as a developer, you'll be using another environment for coding. As for the --save-dev flag, I think that was probably unnecessary. You could have probably just gotten away with:

sudo npm install colors --save

Hope this helps.

Jeremy Castanza:

Thanks for your reply. I don't know if using "sudo" would have made any difference.

The issue is the different versions of bcrypt & Workspaces Python. Both were updated since the instructor created his video.

All I can do is take notes at this point. I'm using WorkSource Oregon Windows 7 OS computers to do my courses using Treehouse's Workspace as that is what is available to me. I'm new to coding & not very familiar with Ubuntu Linux or using command line codes.

I'm otherwise (since mid-Sept. 2016) using a Windows 10 OS with Command Prompt. Still not sure how to adjust Treehouse lessons using them. It's not knowing what to do when I get messages like what I posted above.

Andrew Chalkley:

It might have helped if you had mentioned "npm --save-exact," & "npm --save -E" with "npm --save" or "npm --save-dev --save-exact" flags to save the exact "bcrypt 0.8.3" version since "bcrypt 0.8.7" was the current version which appeared when doing this lesson at the time I did it. However, it might not have helped if the Workspaces "Python 2.7.5" was updated to "Python 3.5.0" since I did this lesson.

This concept was mentioned in the "Building a MEAN Application > Introduction to the MEAN Stack > Setting up an Express Application," Section 1, Video 3, lesson 4.