2

I have a fresh installation of ArchLinux, NodeJS (v 5.2.0) and NPM (v 3.5.2). When I try to install any module (for example express-generator with npm install express-generator, same problem if I do it globally or any other package) the installation doesn't create a folder with the module's name in the node_modules folder and, inside, his own node_modules with its dependencies. Making myself clear, npm installs the modules and all his dependencies in the topmost level so, when I run a ls, I get something like this:

node_modules/
bootstrap commander express-generator mkdirp ... etc

Instead of:

node_modules/
bootstrap/
  node_modules/...
express-generator/
  node_modules/commander mkdirp ... etc

Recently, I tested this procedure in a virtual machine wiht Windows 7 and another with Debian 8 getting the second result. It happend with every module that I installed.

I don't know if that is a "new" behavior of npm's modules or a mistake in any of my configurations. Any help will be grateful. In advance, thank you very much.

  • I'm using the 5.2.0 version of Node and the 3.5.2 version of NPM. – Sebastián Reverso Dec 18 '15 at 16:04
  • Hi, I'm also having this issue on the latest version of Arch Linux, Node version 7.6.0 and NPM version 4.2.0. Have you been able to find a solution for this issue? – TK421 Mar 01 '17 at 02:06
  • Hi TK421. It keeps working in this way. I'd have to install Arch on another pc and got the same behavior. I think that it is normal and depending on what OS you use. I would like to point out that I never have any functionality trouble with this behavior – Sebastián Reverso Mar 01 '17 at 03:24
  • Cool, thanks for the response. – TK421 Mar 01 '17 at 03:41

1 Answers1

0

express-generator should be installed globally (with -g). Even if you don't have root permissions, there are solutions for installing it globally. This way you have the express command made available to you so you can create an app skeleton. I don't find any value in local installation, regardless if it works or not.

Community
  • 1
  • 1
mihai
  • 37,072
  • 9
  • 60
  • 86
  • Hi mihai thank you for your answer and excuse me for the delay in mine's. Even when I install the modules globally, npm keeps saving all the dependencies in one folder without split it. – Sebastián Reverso Dec 21 '15 at 11:23
  • I'm not sure what you mean. Are you talking about dependencies for `express-generator`? They should be installed in the same (global) folder. – mihai Dec 21 '15 at 14:56
  • Excuse me, obviously I wasn't clear with my problem. The `express-generator` case was an example. When I install it or any other npm package (for instance `jshint`, `bootstrap`, etc) this modules doesn't create his own node_modules folder but put all the depencencies in the same folder, so I have the `express-generator`, `jshint`, `commander`, `mkdirp`, etc and all its dependencies in only one folder. In resume, after the installation of 2 or 3 npm packages, I have a unique node_modules folder with a heap of folders inside it. – Sebastián Reverso Dec 21 '15 at 15:23
  • ok, I see now. They are installed at the topmost level, see [algorithm](https://docs.npmjs.com/cli/install#algorithm). Indeed this behavior might've been different in the past, but I can't say for sure. Maybe if you rephrase your question you can get a better answer. – mihai Dec 21 '15 at 16:41