0

In order to build frontend sources on Windows 7 with gulp.js I have a package.json file with node_modules dependencies defined in it:

{
  "name": "custom-repo-name",
  "version": "1.0.0",
  "description": "",
  "main": "gulpfile.js",
  "directories": {
    "doc": "doc"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "gulp-concat": "^2.5.2",
    "gulp-stylus": "^2.0.3",
    "gulp-uglify": "^1.2.0",
    "rimraf": "^2.3.4"
  },
  "devDependencies": {
    "gulp": "^3.9.0",
    "gulp-concat": "^2.5.2",
    "gulp-rev": "^4.0.0",
    "gulp-stylus": "^2.0.3",
    "gulp-uglify": "^1.2.0",
    "gulp-watch": "^4.2.4",
    "rimraf": "^2.3.4"
  }
}

For some reason when I run

npm install

the dependencies are installed locally into .\node_modules folder and gulp command runs properly.

But when I run

npm install -g,

as I can see from the output, a part of dependencies is missing to be installed and running gulp command fails with an error of failed load of dependencies (gulp-uglify.js for instance).

What's wrong?

Andrey Pesoshin
  • 1,136
  • 1
  • 14
  • 30
  • Why are you trying to use -g in this case? doesn't make much sense. – Kevin B Jun 25 '15 at 20:50
  • @KevinB shame on me, I missed to tell the background. The problem is really that I can't afford a TeamCity agent to install all npm dependencies **locally** everytime it runs a build. It will take too much time, because the working folder location is dynamic and then i'll have to dynamically install npm dependencies on and on. So the idea is to have all the dependencies installed globally and just run `gulp` from the working folder when TC has to build a project. – Andrey Pesoshin Jun 25 '15 at 21:19
  • 1
    you can't `require` globally installed modules, so i don't think that's going to help you much. – Kevin B Jun 25 '15 at 21:35
  • You can set your [`NODE_PATH`](https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders) variable to point to the location where your globally installed modules are. [Beware though...](https://github.com/creationix/nvm/issues/586) – laggingreflex Jun 25 '15 at 22:11
  • @KevinB well, it sounds strange to me, but explains much. Thanks for the comment. – Andrey Pesoshin Jun 25 '15 at 23:08
  • @laggingreflex already set, but it doesn't make an effect for some reason – Andrey Pesoshin Jun 25 '15 at 23:08
  • @KevinB where can I read more about this behavior? – Andrey Pesoshin Jun 26 '15 at 09:09
  • http://stackoverflow.com/questions/15636367/nodejs-require-a-global-module-package – Kevin B Jun 26 '15 at 14:11

0 Answers0