1

Environment

Ubuntu 17.04

Steps

Installed Node via official instructions:

curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs

Installed gulp via official instructions:

npm install --global gulp-cli

Which caused permission errors:

Error: EACCES: permission denied, access '/usr/lib/node_modules'

So followed relevant official instructions:

# Make a directory for global installations:
mkdir ~/.npm-global

# Configure npm to use the new directory path:
npm config set prefix '~/.npm-global'

# Open or create a ~/.profile file and add this line:
export PATH=~/.npm-global/bin:$PATH

# Back on the command line, update your system variables:
source ~/.profile

Created a package.json file in my project folder with this content:

{
  "devDependencies": {
  },
  "dependencies": {}
}

Ran the following in my project folder:

npm install gulp --save-dev
npm install gulp-clean-css --save-dev
npm install gulp-concat --save-dev
npm install gulp-rename --save-dev
npm install gulp-sass --save-dev
npm install gulp-uglify --save-dev
npm install pump --save-dev
npm install uglify-js-harmony --save-dev

Which then populated the package.json file so it looked like:

{
  "devDependencies": {
    "gulp": "^3.9.1",
    "gulp-clean-css": "^3.3.1",
    "gulp-concat": "^2.6.1",
    "gulp-rename": "^1.2.2",
    "gulp-sass": "^3.1.0",
    "gulp-uglify": "^3.0.0",
    "pump": "^1.0.2",
    "uglify-js-harmony": "^2.7.7"
  },
  "dependencies": {}
}

Then:

npm install --global gulp-cli

The relevant task in gulpfile.js looks like this:

// BEGIN get gulp plugins
var gulp = require('gulp');
var pump = require('pump');
var rename = require('gulp-rename');
var uglifyjs = require('uglify-js-harmony'); 
var minifier = require('gulp-uglify/minifier');
var cleanCSS = require('gulp-clean-css');
var concat = require('gulp-concat');
// END get gulp plugins

gulp.task('bundle_js', function () {
  // the same options as described above 
  var options = {
    preserveComments: 'license'
  };

  pump([
      gulp.src('scripts/*.js'),
      minifier(options, uglifyjs),
      concat('script_bundle.js'),
      gulp.dest('scripts_bundled')
    ]
  );
});

Running:

gulp bundle_js

Causes this error:

throw err;
    ^

Error: Cannot find module 'gulp-uglify/minifier'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/me/Desktop/myGulpProject/gulpfile.js:6:16)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)

What I've Tried:

I tried manually removing the node_modules folder in my project folder and then running:

npm install --save-dev

I also tried:

npm uninstall -g gulp
npm install -g gulp
rm -rf node_modules
npm install 

From: https://stackoverflow.com/a/42090366/1063287

I then tried uninstalling and re-installing node, npm and gulp:

npm uninstall gulp -g

sudo apt-get remove nodejs
sudo apt-get remove npm

from: https://stackoverflow.com/a/33947181/1063287

cd /usr/local/lib/
sudo rm -rf node_modules/

cd ~
rm -rf .npm
rm -rf .npm-global
rm -rf .npmrc 

from: https://stackoverflow.com/a/11178106/1063287

vim .profile // and commented out line added previously to address permission errors

And removed node_modules folder from my project folder.

And then re-installed as described above.

I still have the same error.

throw err;
    ^

Error: Cannot find module 'gulp-uglify/minifier'
Community
  • 1
  • 1
user1063287
  • 10,265
  • 25
  • 122
  • 218
  • npm install gulp-uglify/minifier --save-dev – Dayan Moreno Leon May 21 '17 at 04:32
  • Prompted: `The authenticity of host 'github.com (192.30.255.112)' can't be established. RSA key fingerprint is SHA256:xxx. Are you sure you want to continue connecting (yes/no)?`. I entered `yes` and got errors like `ERR! git clone`, `Permission denied (publickey)`, `fatal: Could not read from remote repository.` – user1063287 May 21 '17 at 04:36
  • Also: `Warning: Permanently added 'github.com,192.30.255.112' (RSA) to the list of known hosts.` – user1063287 May 21 '17 at 04:45
  • First you can create ssh key for git account for system where you want to clone your repo.Then Run your script file. – Yash May 21 '17 at 06:10
  • download the zip project from git then move it to your `node_modules` directory , install the module dependencies if you dont have them @user1063287 – farhadamjady May 21 '17 at 16:56
  • 2
    There's no `gulp-uglify/minifier` anymore, the package was updated https://github.com/terinjokes/gulp-uglify/releases – berrtech May 22 '17 at 14:57

0 Answers0