Friday 18 December 2015

New to Node. I find npm very rough around the edges.

This is a bit of a rant and some specific questions, so please bear with me. My background is in Java but I'm transitioning to front-end dev (it's a long story; I just find myself enjoying dynamic programming these days)I came to Node by way of Angular. The seed project for angular utilizes a node container with end-2-end testing utilizing node packages. Other than running some tests and using node as a http server, I'm not doing much on the server side and my knowledge of node/npm is basic: defining dependencies in package.json, installing npm packages (global and proj specific) and that's it.My trouble so far has been with npm in particular. I understand it's inspired by Ruby gems and my experience is with jars and ant/maven in the java world. What I find confusing is all the conflicts with versions and compatibility between Node and NPM. Node ships with npm, but then npm can be installed separately and there seem to be issues with interoperability/versions; every time I've run into issues and checked stackoverflow or elsewhere, people usually suggest updating versions. It just doesn't seem well-documented.npm as a tool itself doesn't provide the best answers even with logging level set to verbose. For example I get an install fail with npm ERR! code 1 and searching for it produces no documentation other than posts by people who are seeing similar issues. There was another error I got which just told me that issue is with the package itself and not npm and that's it. Not running on top of some VM or node itself, npm seems too tightly tied to the OS and therefore has issues related to sudo privileges, global vs local installs and it's just not as solid/mature as the packaging/build tools in the java world.I wish I could package all the dependencies into a single archive like with java WAR or EAR files that's all-inclusive and drop it onto a VM to deply not having to worry about recreating a similar runtime environment where dependencies have to be downloaded and installed separately.--rant over--Over to my question. My local version of the Node app which just serves a few html and javascript files runs ok. I signed up for a heroku account to host this node 'app' and heroku allows one to push git commits directly to their site and it builds the environment from the same package.json as my local machine. Heroku errors out every time on the same build and doesn't create the proj or node_modules folder, whereas on my local machine even though I see the error, it actually creates the node_modules folder and starting up the app it seems to work fine.I can provide more detail if anyone is interested, but my first question is generic: have you guys faced something similar with problems setting up a node environment to run your code and had issues with installing packages on two different environments? If so, what are some of the things to watch out for? I know one is to be careful about global packages and another is to specify node and npm versions explicitiy in the 'engines' param.Second, what's a good resource/tutorial to get a handle on using npm?Thanks

Submitted December 18, 2015 at 04:43PM by vgn

No comments:

Post a Comment