Closed agarwal closed 7 years ago
I'm on it @agarwal. Thanks for the proposition. I will consider your solution.
What do we do with this? I just installed OS on a fresh system. It is too difficult to find out how to install npm dependencies ...
It is too difficult to find out how to install npm dependencies
How so? You just type npm install foo
. Or do you mean installing npm
itself?
I mean that in the current state, it is difficult for a beginner to understand that he must install npm, what is npm, and then which npm package to install. :) We are trying to make Ocsigen Start very easy to use for very beginners ;)
I'm a beginner to the JavaScript ecosystem, so my suggestions come with that caveat. I've read some blogs that criticize npm
, but from what I can tell npm
is the opam
of JavaScript. Everybody uses it. So I thought npm
is a reasonable prerequisite even for beginners. I could definitely be wrong.
What's the alternative? Right now a beginner has to figure out how to install postcss
and then sassc
and so on. A beginner is still stuck.
then which npm package to install
Assuming npm
is installed, my proposal eliminates this issue. The point is the Makefile would install all the necessary npm
packages automatically.
Indeed. I like your suggestion. It's one of the very least things to do before 1.0. There is a PR that is still not merged ... 🙂
I should point out that NPM version 3 changed the way it organizes the node_modules
directory. See https://github.com/npm/npm/releases/tag/v3.0.0, section “Flat, flat, flat!”. Unfortunately, the directory structure is now non-deterministic. For instance, if you do npm install foo
and you end up with node_modules/foo
, there is is no guarantee node_modules/foo
will remain as it is. Subsequently doing npm install bar
might completely change the contents of node_modules/foo
.
In my own code, I've gotten around this by having my Makefile install all npm packages at once. Then I can rely on the directory structure being a certain way. However, this seems fragile. At the least my code now requires npm > 3 (which is easy for me to satisfy internally), but maybe not great for a public project.
Another option to consider is to download all JavaScript packages with curl/wget. Then you you know exactly what you're getting and can control exactly where specific files go. Downside is you lose the benefits of a package manager. You have to know all the packages you want to install and their dependencies. Even if you figure it out once, you'll have to redo the work every time you want to upgrade to newer versions of JavaScript packages.
I keep hitting errors due to missing npm packages. First issue was that
postcss
wasn't installed. I installed that, then updated the Makefile as needed. Then I got errors aboutsassc
andautoprefixer
not being found.You might want to consider the Makefile I used for cufp.org. The main points are:
postcss=node_modules/.bin/postcss
.site/css/app.css
.The net result is that a simple
make
does a lot more to help people get started.