Day 9 - screeps, npm + python = ugh


Every couple months I’ll pick up the game [screeps]() and have an absolute ton of fun programming and writing some [really crazy code]() that I’d never use in a production setting. It’s always a ton of fun to dive into old code, have those a-ha moments when I remember what I was doing, then trashing the whole thing and refactoring it into a beautiful new monster.

NPM errors because of python??

Was setting up a local screeps server and ran into this issue when running npm i -g screep

Exit code: 1
Command: node-gyp rebuild --release -j 4
Directory: /Users/me/.config/yarn/global/node_modules/isolated-vm
gyp info it worked if it ends with ok
gyp info using node-gyp@3.8.0
gyp info using node@8.12.0 | darwin | x64
gyp ERR! configure error
gyp ERR! stack Error: Command failed: /Users/me/miniconda3/bin/python -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack   File "<string>", line 1
gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack                                ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:276:12)
gyp ERR! stack     at emitTwo (events.js:126:13)
gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
gyp ERR! stack     at maybeClose (internal/child_process.js:915:16)
gyp ERR! stack     at (internal/child_process.js:336:11)
gyp ERR! stack     at emitOne (events.js:116:13)
gyp ERR! stack     at Socket.emit (events.js:211:7)
gyp ERR! stack     at Pipe._handle.close [as _onclose] (net.js:561:12)
gyp ERR! System Darwin 18.0.0
gyp ERR! command "/Users/me/.nvm/versions/node/v8.12.0/bin/node" "/Users/me/.nvm/versions/node/v8.12.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--release" "-j" "4"
gyp ERR! cwd /Users/me/.config/yarn/global/node_modules/isolated-vm

This blew my mind for a second until I realized - of course - Python is fucking things up for everyone again. So TIL you can specify which version of Python to use in the context of npm or a node process like so npm i -g screeps --python=python2.7. The more you know!