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 Creating Your Own Arbitrary Tasks

James McDonough
James McDonough
15,618 Points

Several commands don't work, uglify can't be found, workspaces keeps "losing connection"

This and the previous node.js and npm courses are really severely out of date and I've been jumping through so many extra hoops just to try to make this stuff work so I can understand it. So far I've done neither.

My current problem is about the middle of the video, when you're supposed to run "npm run uglify"

dice_simulator_2015@1.0.0 uglify /home/treehouse/workspace
uglifyjs src/models/* src/frontend.js -m -c -o build/app.js

sh: uglifyjs: command not found

npm ERR! Linux 4.4.68-1.el7.elrepo.x86_64
npm ERR! argv "/usr/local/nodejs-binary-6.11.1/bin/node" "/usr/local/nod ejs-binary/bin/npm" "run" "uglify"
npm ERR! node v6.11.1
npm ERR! npm v3.10.10
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! dice_simulator_2015@1.0.0 uglify: uglifyjs src/models/* src/fr ontend.js -m -c -o build/app.js
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the dice_simulator_2015@1.0.0 uglify script 'uglifyjs src/models/* src/frontend.js -m -c -o build/app.js'.
npm ERR! Make sure you have the latest version of node.js and npm instal led.
npm ERR! If you do, this is most likely a problem with the dice_simulato r_2015 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! uglifyjs src/models/* src/frontend.js -m -c -o build/app.js npm ERR! You can get information on how to open an issue for this projec t with:
npm ERR! npm bugs dice_simulator_2015
npm ERR! Or if that isn't available, you can get their info via: npm ERR! npm owner ls dice_simulator_2015
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /home/treehouse/workspace/npm-debug.log

Also treehouse workspaces keeps failing, refreshing, and losing all of my progress.

It really sucks that I have to drudge through this stuff to complete the javascript course!

My friend, i do recommend you to save all your progress locally, about your "uglifyjs", do you run "npm install --save uglifyjs" ?

1 Answer

Neil McPartlin
Neil McPartlin
14,662 Points

Hi James. About 'uglifyjs', if you would like to make a 'snapshot' of your workspace, I'd be happy to take a look at it for you. I have just covered this course and yes it is old, but I didn't stagger over any tripwires.

Based on what you have shown above, I think your uglifyjs entry in your package.json is OK. I also wondered whether you had previously deleted your entire node_modules folder. I deleted mine then ran npm run uglify. I got exactly the same error message as you except, where you have a blank line, I got npm WARN Local package.json exists, but node_modules missing, did you mean to install?

So as mentioned by Iagor, it would be worth checking that 'uglify-js' is installed. Try npm list uglify-js. Assuming it is, and as shown in the video around the 2 minute mark, enter this in your console...

node_modules/.bin/uglifyjs src/models/* src/frontend.js -m -c -o build/app.js

...to make sure this works independently of your package.json entry.

As for your complaint about workspaces, I see this too a lot, once or twice an hour. I don't have the best of Internet connections but I can live with it. I have developed a nervous twitch so that I am constantly using CTRL+S so that when I lose the connection, I don't lose the data too. I'm about to hit the 100 workspace limit too so as Iagor says, I may well do more coding locally instead.