0

This is driving me crazy. I am in charge of the development and need to do merging of branches, but exactly on my machine only something is not working.

I have several times removed node_modules and run npm install, and even completely cloned the repo and setup everything again, and always I will get the same issue.

Someone merged code with ES6, so we need to transpile it, because the minifier plugin does not work with ES6 code.

So we use gulp-babel

var
          gulp  = require('gulp')
         //more requires
        , babel = require('gulp-babel')

var libs_js = [
   //list of javascripts
]

gulp.task('js-build', function () {
  gulp.src(libs_js)
    .pipe(sourcemaps.init())
    .pipe(ngAnnotate())
    .pipe(running_task != 'js-build' ? _bypass() : tap(function(f) { f.contents = new Buffer('document.write(\'<script src="' + f.path.replace(process.cwd(), '') 
        .replaceAll('\\','/') // fix paths for windows
      + '"><\/script>\')') })) 
    .pipe(concat(pkg.name + '.js', {newLine: '\n;'}))
    .pipe(babel({presets: ['es2015'],compact: false}))
    .pipe(running_task == 'js-build' ? _bypass() : uglify())
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest('dist'))
    .on('end', function () {
      console.log('[' + new Date + '] js compiled')
    })  
});

//other gulp targets

gulp.task('prod', ['js-build', 'css', 'sass', 'assets', 'libs']);

running gulp prod, for everyone it works, BUT for me, I get:

...
[Wed Oct 26 2016 22:05:51 GMT-0500 (COT)] asset completedd

events.js:141
      throw er; // Unhandled 'error' event
      ^
Error: Couldn't find preset "latest" relative to directory "/home/me/prj/src"
    at /home/me/prj/src/frontend/node_modules/babel-core/lib/transformation/file/options/option-manager.js:299:19

First, why complaining about "latest", if in the code we use es2015. I went and ran everything on an other computer, where it worked, and I found something astonishing:

On my machine:

>$ npm list | grep babel
├─┬ babel-preset-es2015@6.18.0
│ ├─┬ babel-plugin-check-es2015-constants@6.8.0
│ │ └─┬ babel-runtime@6.18.0
│ ├── babel-plugin-transform-es2015-arrow-functions@6.8.0
│ ├── babel-plugin-transform-es2015-block-scoped-functions@6.8.0
│ ├─┬ babel-plugin-transform-es2015-block-scoping@6.18.0
│ │ ├─┬ babel-template@6.16.0
│ │ ├─┬ babel-traverse@6.18.0
│ │ ├─┬ babel-types@6.18.0
│ ├─┬ babel-plugin-transform-es2015-classes@6.18.0
│ │ ├─┬ babel-helper-define-map@6.18.0
│ │ ├── babel-helper-function-name@6.18.0
│ │ ├── babel-helper-optimise-call-expression@6.18.0
│ │ ├── babel-helper-replace-supers@6.18.0
│ │ └── babel-messages@6.8.0
│ ├── babel-plugin-transform-es2015-computed-properties@6.8.0
│ ├── babel-plugin-transform-es2015-destructuring@6.18.0
│ ├── babel-plugin-transform-es2015-duplicate-keys@6.8.0
│ ├── babel-plugin-transform-es2015-for-of@6.18.0
│ ├── babel-plugin-transform-es2015-function-name@6.9.0
│ ├── babel-plugin-transform-es2015-literals@6.8.0
│ ├── babel-plugin-transform-es2015-modules-amd@6.18.0
│ ├─┬ babel-plugin-transform-es2015-modules-commonjs@6.18.0
│ │ └── babel-plugin-transform-strict-mode@6.18.0
│ ├─┬ babel-plugin-transform-es2015-modules-systemjs@6.18.0
│ │ └── babel-helper-hoist-variables@6.18.0
│ ├── babel-plugin-transform-es2015-modules-umd@6.18.0
│ ├── babel-plugin-transform-es2015-object-super@6.8.0
│ ├─┬ babel-plugin-transform-es2015-parameters@6.18.0
│ │ ├── babel-helper-call-delegate@6.18.0
│ │ └── babel-helper-get-function-arity@6.18.0
│ ├── babel-plugin-transform-es2015-shorthand-properties@6.18.0
│ ├── babel-plugin-transform-es2015-spread@6.8.0
│ ├─┬ babel-plugin-transform-es2015-sticky-regex@6.8.0
│ │ └─┬ babel-helper-regex@6.18.0
│ ├── babel-plugin-transform-es2015-template-literals@6.8.0
│ ├── babel-plugin-transform-es2015-typeof-symbol@6.18.0
│ ├─┬ babel-plugin-transform-es2015-unicode-regex@6.11.0
│ └─┬ babel-plugin-transform-regenerator@6.16.1
├─┬ gulp-babel@6.1.2
│ ├─┬ babel-core@6.18.0
│ │ ├─┬ babel-code-frame@6.16.0
│ │ ├─┬ babel-generator@6.18.0
│ │ ├── babel-helpers@6.16.0
│ │ ├─┬ babel-register@6.18.0

On the other one:

$ npm list | grep babel
├─┬ babel-preset-es2015@6.18.0
│ ├─┬ babel-plugin-check-es2015-constants@6.8.0
│ │ └─┬ babel-runtime@6.18.0
│ ├─┬ babel-plugin-transform-es2015-arrow-functions@6.8.0
│ │ └─┬ babel-runtime@6.18.0
│ ├─┬ babel-plugin-transform-es2015-block-scoped-functions@6.8.0
│ │ └─┬ babel-runtime@6.18.0
│ ├─┬ babel-plugin-transform-es2015-block-scoping@6.18.0
│ │ ├─┬ babel-runtime@6.18.0
│ │ ├─┬ babel-template@6.16.0
│ │ ├─┬ babel-traverse@6.18.0
│ │ │ ├─┬ babel-code-frame@6.16.0
│ │ │ ├── babel-messages@6.8.0
│ │ ├─┬ babel-types@6.18.0
│ ├─┬ babel-plugin-transform-es2015-classes@6.18.0
│ │ ├─┬ babel-helper-define-map@6.18.0
│ │ ├─┬ babel-helper-function-name@6.18.0
│ │ │ └── babel-helper-get-function-arity@6.18.0
│ │ ├── babel-helper-optimise-call-expression@6.18.0
│ │ ├── babel-helper-replace-supers@6.18.0
│ │ ├── babel-messages@6.8.0
│ │ ├─┬ babel-runtime@6.18.0
│ │ ├─┬ babel-template@6.16.0
│ │ ├─┬ babel-traverse@6.18.0
│ │ │ ├─┬ babel-code-frame@6.16.0
│ │ └─┬ babel-types@6.18.0
│ ├─┬ babel-plugin-transform-es2015-computed-properties@6.8.0
│ │ ├─┬ babel-helper-define-map@6.18.0
│ │ │ ├─┬ babel-helper-function-name@6.18.0
│ │ │ │ ├── babel-helper-get-function-arity@6.18.0
│ │ │ │ └─┬ babel-traverse@6.18.0
│ │ │ │   ├─┬ babel-code-frame@6.16.0
│ │ │ │   ├── babel-messages@6.8.0
│ │ │ ├─┬ babel-types@6.18.0
│ │ ├─┬ babel-runtime@6.18.0
│ │ └─┬ babel-template@6.16.0
│ │   ├─┬ babel-traverse@6.18.0
│ │   │ ├─┬ babel-code-frame@6.16.0
│ │   │ ├── babel-messages@6.8.0
│ │   ├─┬ babel-types@6.18.0
│ ├─┬ babel-plugin-transform-es2015-destructuring@6.18.0
│ │ └─┬ babel-runtime@6.18.0
│ ├─┬ babel-plugin-transform-es2015-duplicate-keys@6.8.0
│ │ ├─┬ babel-runtime@6.18.0
│ │ └─┬ babel-types@6.18.0
│ ├─┬ babel-plugin-transform-es2015-for-of@6.18.0
│ │ └─┬ babel-runtime@6.18.0
│ ├─┬ babel-plugin-transform-es2015-function-name@6.9.0
│ │ ├─┬ babel-helper-function-name@6.18.0
│ │ │ ├── babel-helper-get-function-arity@6.18.0
│ │ │ ├─┬ babel-template@6.16.0
│ │ │ └─┬ babel-traverse@6.18.0
│ │ │   ├─┬ babel-code-frame@6.16.0
│ │ │   ├── babel-messages@6.8.0
│ │ ├─┬ babel-runtime@6.18.0
│ │ └─┬ babel-types@6.18.0
│ ├─┬ babel-plugin-transform-es2015-literals@6.8.0
│ │ └─┬ babel-runtime@6.18.0
│ ├─┬ babel-plugin-transform-es2015-modules-amd@6.18.0
│ │ ├─┬ babel-runtime@6.18.0
│ │ └─┬ babel-template@6.16.0
│ │   ├─┬ babel-traverse@6.18.0
│ │   │ ├─┬ babel-code-frame@6.16.0
│ │   │ ├── babel-messages@6.8.0
│ │   ├─┬ babel-types@6.18.0
│ ├─┬ babel-plugin-transform-es2015-modules-commonjs@6.18.0
│ │ ├── babel-plugin-transform-strict-mode@6.18.0
│ │ ├─┬ babel-runtime@6.18.0
│ │ ├─┬ babel-template@6.16.0
│ │ │ ├─┬ babel-traverse@6.18.0
│ │ │ │ ├─┬ babel-code-frame@6.16.0
│ │ │ │ ├── babel-messages@6.8.0
│ │ └─┬ babel-types@6.18.0
│ ├─┬ babel-plugin-transform-es2015-modules-systemjs@6.18.0
│ │ ├─┬ babel-helper-hoist-variables@6.18.0
│ │ │ └─┬ babel-types@6.18.0
│ │ ├─┬ babel-runtime@6.18.0
│ │ └─┬ babel-template@6.16.0
│ │   ├─┬ babel-traverse@6.18.0
│ │   │ ├─┬ babel-code-frame@6.16.0
│ │   │ ├── babel-messages@6.8.0
│ │   ├─┬ babel-types@6.18.0
│ ├─┬ babel-plugin-transform-es2015-modules-umd@6.18.0
│ │ ├─┬ babel-runtime@6.18.0
│ │ └─┬ babel-template@6.16.0
│ │   ├─┬ babel-traverse@6.18.0
│ │   │ ├─┬ babel-code-frame@6.16.0
│ │   │ ├── babel-messages@6.8.0
│ │   ├─┬ babel-types@6.18.0
│ ├─┬ babel-plugin-transform-es2015-object-super@6.8.0
│ │ ├─┬ babel-helper-replace-supers@6.18.0
│ │ │ ├── babel-helper-optimise-call-expression@6.18.0
│ │ │ ├── babel-messages@6.8.0
│ │ │ ├─┬ babel-template@6.16.0
│ │ │ ├─┬ babel-traverse@6.18.0
│ │ │ │ ├─┬ babel-code-frame@6.16.0
│ │ │ └─┬ babel-types@6.18.0
│ │ └─┬ babel-runtime@6.18.0
│ ├─┬ babel-plugin-transform-es2015-parameters@6.18.0
│ │ ├─┬ babel-helper-call-delegate@6.18.0
│ │ │ └── babel-helper-hoist-variables@6.18.0
│ │ ├── babel-helper-get-function-arity@6.18.0
│ │ ├─┬ babel-runtime@6.18.0
│ │ ├─┬ babel-template@6.16.0
│ │ ├─┬ babel-traverse@6.18.0
│ │ │ ├─┬ babel-code-frame@6.16.0
│ │ │ ├── babel-messages@6.8.0
│ │ └─┬ babel-types@6.18.0
│ ├─┬ babel-plugin-transform-es2015-shorthand-properties@6.18.0
│ │ ├─┬ babel-runtime@6.18.0
│ │ └─┬ babel-types@6.18.0
│ ├─┬ babel-plugin-transform-es2015-spread@6.8.0
│ │ └─┬ babel-runtime@6.18.0
│ ├─┬ babel-plugin-transform-es2015-sticky-regex@6.8.0
│ │ ├─┬ babel-helper-regex@6.18.0
│ │ ├─┬ babel-runtime@6.18.0
│ │ └─┬ babel-types@6.18.0
│ ├─┬ babel-plugin-transform-es2015-template-literals@6.8.0
│ │ └─┬ babel-runtime@6.18.0
│ ├─┬ babel-plugin-transform-es2015-typeof-symbol@6.18.0
│ │ └─┬ babel-runtime@6.18.0
│ ├─┬ babel-plugin-transform-es2015-unicode-regex@6.11.0
│ │ ├─┬ babel-helper-regex@6.18.0
│ │ │ ├─┬ babel-types@6.18.0
│ │ ├─┬ babel-runtime@6.18.0
│ └─┬ babel-plugin-transform-regenerator@6.16.1
│   ├─┬ babel-runtime@6.18.0
│   ├─┬ babel-types@6.18.0
├─┬ gulp-babel@6.1.2
│ ├─┬ babel-core@6.18.0
│ │ ├─┬ babel-code-frame@6.16.0
│ │ ├─┬ babel-generator@6.18.0
│ │ ├── babel-helpers@6.16.0
│ │ ├── babel-messages@6.8.0
│ │ ├─┬ babel-register@6.18.0
│ │ ├─┬ babel-runtime@6.18.0
│ │ ├── babel-template@6.16.0
│ │ ├─┬ babel-traverse@6.18.0
│ │ ├─┬ babel-types@6.18.0

They are different!!!! How the heck is this even possible??? I mean I used the exact same commands on both machines, package.json is the same for everybody, and no different command other than npm install and gulp prod has been run (I even used gulp from node_modules/.bin/gulp)

The only things I could think of: - There's something binary which could cause problems - node or npm versions? Using node 5.1 here - Some concurrency issue, as my PC is using SSD storage?

For reference, here package.json

{
  "name": "Proj",
  "version": "0.1.0",
  "description": "", 
  "main": "index.js",
  "scripts": {
    "heroku-postbuild": "bower install && gulp prod"
  },  
  "author": "", 
  "license": "ISC",
  "devDependencies": {
    "babel-preset-es2015": "^6.18.0",
    "concurrently": "^2.2.0",
    "gulp": "^3.9.1",
    "gulp-babel": "^6.1.2",
    "gulp-concat": "^2.6.0",
    "jasmine-core": "^2.4.1",
    "karma": "^1.1.2",
    "karma-coverage": "^1.1.1",
    "karma-jasmine": "^1.0.2",
    "karma-phantomjs-launcher": "^1.0.1",
    "mkdirp": "^0.5.1"
  },  
  "dependencies": {
    "bower": "^1.7.9",
    "colors": "^1.1.2",
    "compression": "^1.6.2",
    "es6-promise": "^3.2.1",
    "express": "^4.14.0",
    "fb-watchman": "^1.9.0",
    "gulp": "^3.9.1",
    "gulp-autoprefixer": "^3.1.1",
    "gulp-concat": "^2.6.0",
    "gulp-minify-css": "^1.2.4",
    "gulp-ng-annotate": "^2.0.0",
    "gulp-plumber": "^1.1.0",
    "gulp-sass": "^2.3.2",
    "gulp-sourcemaps": "^1.6.0",
    "gulp-tap": "^0.1.3",
    "gulp-uglify": "^2.0.0",
    "request": "^2.74.0",
    "uglify-js": "^2.7.4"
  }
}
transient_loop
  • 5,984
  • 15
  • 58
  • 117

1 Answers1

1

Add this to your package.json

"babel": { "presets": [ "es2015" ] },

or to an existing .babelrc if you have one

Mark Holland
  • 127
  • 1
  • 10
  • Hey thanks Mark, this has been so troublesome for us that we had to revert pull requests in order to get us further. I can't reproduce this anymore now, so I can't accept your answer as I can't verify, but I'll upvote :) Thanks! – transient_loop Nov 04 '16 at 04:49