foundation-sites: ZURB/template fails to load Babel

What should happen?

Upon runnig Gulp the dist folder should be build properly. …

What happens instead?

After a clean install , running yarn install and running gulp The terminal gives:

[09:31:15] Failed to load external module babel-register
[09:31:15] Failed to load external module babel-core/register
[09:31:15] Failed to load external module babel/register
/Users/rdg/Documents/REPOSITORY/xxx/gulpfile.babel.js:3
import plugins       from 'gulp-load-plugins';
       ^^^^^^^

SyntaxError: Unexpected identifier
    at new Script (vm.js:80:7)
    at createScript (vm.js:264:10)
    at Object.runInThisContext (vm.js:316:10)
    at Module._compile (internal/modules/cjs/loader.js:670:28)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:718:10)
    at Module.load (internal/modules/cjs/loader.js:605:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:544:12)
    at Function.Module._load (internal/modules/cjs/loader.js:536:3)
    at Module.require (internal/modules/cjs/loader.js:643:17)
    at require (internal/modules/cjs/helpers.js:22:18)

Possible Solution

Test Case and/or Steps to Reproduce (for bugs)

How to reproduce:

  1. clone a fresh repo Master,
  2. run yarn install
  3. and then gulp

Context

Your Environment

Checklist

  • I have read and follow the CONTRIBUTING.md document.
  • There are no other issues similar to this one.
  • The issue title and template are correctly filled.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 23 (18 by maintainers)

Most upvoted comments

Was having the same issue an it cost me hours, but found the solution that worked for me. Add a file in the same directory as the gulpfile.babel.js, called:

.babelrc

Then add:

{ "presets": [ "@babel/preset-env" ] }

Inside it. Run: yarn start or gulp And it should work again.

Sorry Jeremy, I should delete my comment, but I’ll reply first. I spent a few hours last night starting with the Zurb Foundation for Emails installation tutorial, then various forums looking for solutions.

Failed to load external module @babel/register was a common error amongst others. I was starting to feel like I was going round in circles. I am not familiar enough to understand what the problem really is.

I got here via search, but this seems to be an obvious notification when running the script, where the script itself, does not brake. But I just started a new foundation-sites project and I can get it to work. When running foundation-watch or gulp I get

/Users/name/Documents/webdevelopment/xx/gulpfile.babel.js:3
import plugins from 'gulp-load-plugins';
       ^^^^^^^

SyntaxError: Unexpected identifier
    at Module._compile (internal/modules/cjs/loader.js:723:23)
    at Module._compile (/Users/name/Documents/webdevelopment/xx/node_modules/pirates/lib/index.js:99:24)
    at Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Object.newLoader [as .js] (/Users/name/Documents/webdevelopment/xx/node_modules/pirates/lib/index.js:104:7)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at execute (/Users/name/Documents/webdevelopment/xx/node_modules/gulp-cli/lib/versioned/^4.0.0/index.js:36:18)
Error: foundation-zurb-template@1.0.0 start: `gulp`
Exit status 1
    at EventEmitter.<anonymous> (/usr/local/lib/node_modules/foundation-cli/node_modules/npm/lib/utils/lifecycle.js:217:16)
    at EventEmitter.emit (events.js:198:13)
    at ChildProcess.<anonymous> (/usr/local/lib/node_modules/foundation-cli/node_modules/npm/lib/utils/spawn.js:24:14)
    at ChildProcess.emit (events.js:198:13)
    at maybeClose (internal/child_process.js:982:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)


I tried the solutions in this thread. But these solutions did not help me.

hi i deleted everything in /usr/local/lib/node-modules and now it works.

Despite the error message everything seems to work fine though.

In general this should just be a warning and it is a known problem of the babel-loader.