Closed xskif closed 9 years ago
Can you check if you have the latest version of gulp? And if Babel installed properly?
@arthurvr is the new Gulpfile working for you with https://github.com/google/web-starter-kit/pull/712 included?
gulp -v
[20:49:41] CLI version 3.8.11
[20:49:41] Local version 3.9.0
Babel does not installed, there are nothing about installing third-party libraries except that which contains package.json
This basically means gulp is trying to parse the gulpfile without Babel.
The output of npm ls --depth=0
and gulp --version
would be handy. Also is your gulpfile called gulpfile.babel.js
or did you just update gulpfile.js
? Only the babel version will work.
@addyosmani Yes, everything's alright.
Babel does not installed, there are nothing about installing third-party libraries except that which contains package.json
@paddy2k babel is in our package.json :)
CLI version 3.8.11
You need to update to the latest version using npm i -g gulp
.
babel is in our package.json :)
sorry, did not notice it =)
You need to update to the latest version using npm i -g gulp.
it's ok now, thank you
@xskif Glad it's resolved :)
Hello. I am having here the same issue.
Doing gulp -v returns
Failed to load external module babel/register
CLI version 3.9.0
Local version 3.9.0
Things i know:
Can anyone help me? Thanks in advanced
node 0.10.25
Can you try updating your node version to 0.12.x? I'm not entirely sure if babel even supports 0.10.
Will do.
Ok, I've updated to v0.12.4 but i am having the same results as before.
This started happening when using wsk with babel. Since doing gulp -v returns an error with babel, should i install it manually?
just as a precaution i did
sudo npm install --global gulp && npm install
Also with no luck
Here is the error log. Hope it could help.
gulpfile.babel.js:25
import fs from 'fs';
^^^^^^
SyntaxError: Unexpected reserved word
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Liftoff.handleArguments (/usr/local/lib/node_modules/gulp/bin/gulp.js:116:3)
at Liftoff.<anonymous> (/usr/local/lib/node_modules/gulp/node_modules/liftoff/index.js:192:16)
at module.exports (/usr/local/lib/node_modules/gulp/node_modules/liftoff/node_modules/flagged-respawn/index.js:17:3)
looks like babel do not installed. Did you see output like this?
$ gulp serve
[18:55:48] Requiring external module babel/register
[18:55:49] Using gulpfile ~/www/localhost/wl/markup/gulpfile.babel.js
no. My output is the following
hgomez@fielo-ci:~/workspace/fielo/raw⟫ gulp serve
[17:18:59] Failed to load external module babel/register
/home/hgomez/workspace/fielo/raw/gulpfile.babel.js:25
import fs from 'fs';
^^^^^^
SyntaxError: Unexpected reserved word
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Liftoff.handleArguments (/usr/local/lib/node_modules/gulp/bin/gulp.js:116:3)
at Liftoff.<anonymous> (/usr/local/lib/node_modules/gulp/node_modules/liftoff/index.js:192:16)
at module.exports (/usr/local/lib/node_modules/gulp/node_modules/liftoff/node_modules/flagged-respawn/index.js:17:3)
I know Babel is in the package.json so there should not be any problem. Babel shows at node_modules/babel
Just to make sure babel is installed globally i did
sudo npm install -g babel
but I am in the same situation as before
check if you indeed have babel installed:
$ npm ls babel
If you have it installed, delete the node_modules folder, and rerun your install:
sudo npm install
I do have it :)
@ /home/hgomez/workspace/fielo/raw
└── babel@5.5.6
Now i am deleting the folder and re installing. Thanks for the quick response
Ok. Finally it worked!!!
Thanks a lot to all of you for your support!! This was blocking my current job. You all save my day!!
These where the final messages i got.
npm WARN optional dep failed, continuing fsevents@0.3.6
> optipng-bin@3.0.2 postinstall /home/hgomez/workspace/fielo/raw/node_modules/gulp-imagemin/node_modules/imagemin/node_modules/imagemin-optipng/node_modules/optipng-bin
> node lib/install.js
✔ optipng pre-build test passed successfully
npm WARN optional dep failed, continuing fsevents@0.3.6
> gifsicle@3.0.1 postinstall /home/hgomez/workspace/fielo/raw/node_modules/gulp-imagemin/node_modules/imagemin/node_modules/imagemin-gifsicle/node_modules/gifsicle
> node lib/install.js
✔ gifsicle pre-build test passed successfully
> jpegtran-bin@3.0.2 postinstall /home/hgomez/workspace/fielo/raw/node_modules/gulp-imagemin/node_modules/imagemin/node_modules/imagemin-jpegtran/node_modules/jpegtran-bin
> node lib/install.js
> phantomjs@1.9.17 install /home/hgomez/workspace/fielo/raw/node_modules/gulp-uncss/node_modules/uncss/node_modules/phridge/node_modules/phantomjs
> node install.js
Downloading https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.8-linux-x86_64.tar.bz2
Saving to /tmp/phantomjs/phantomjs-1.9.8-linux-x86_64.tar.bz2
Receiving...
\ [=================================-------] 82% 0.0s\
Received 12854K total.
Extracting tar contents (via spawned process)
Removing /home/hgomez/workspace/fielo/raw/node_modules/gulp-uncss/node_modules/uncss/node_modules/phridge/node_modules/phantomjs/lib/phantom
Copying extracted folder /tmp/phantomjs/phantomjs-1.9.8-linux-x86_64.tar.bz2-extract-1434567108916/phantomjs-1.9.8-linux-x86_64 -> /home/hgomez/workspace/fielo/raw/node_modules/gulp-uncss/node_modules/uncss/node_modules/phridge/node_modules/phantomjs/lib/phantom
Writing location.js file
Done. Phantomjs binary available at /home/hgomez/workspace/fielo/raw/node_modules/gulp-uncss/node_modules/uncss/node_modules/phridge/node_modules/phantomjs/lib/phantom/bin/phantomjs
> ws@0.5.0 install /home/hgomez/workspace/fielo/raw/node_modules/browser-sync/node_modules/socket.io/node_modules/engine.io/node_modules/ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)
SOLINK_MODULE(target) Release/obj.target/bufferutil.node: Finished
COPY Release/bufferutil.node
CXX(target) Release/obj.target/validation/src/validation.o
SOLINK_MODULE(target) Release/obj.target/validation.node
SOLINK_MODULE(target) Release/obj.target/validation.node: Finished
COPY Release/validation.node
make: Leaving directory `/home/hgomez/workspace/fielo/raw/node_modules/browser-sync/node_modules/socket.io/node_modules/engine.io/node_modules/ws/build'
npm WARN deprecated jws@0.0.2: Security update: Versions below 3.0.0 are deprecated.
> ws@0.4.31 install /home/hgomez/workspace/fielo/raw/node_modules/browser-sync/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)
make: Entering directory `/home/hgomez/workspace/fielo/raw/node_modules/browser-sync/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws/build'
CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
make: Leaving directory `/home/hgomez/workspace/fielo/raw/node_modules/browser-sync/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws/build'
npm WARN deprecated tap-consumer@0.0.1: This module is not supported. Please use 'tap' instead.
npm WARN installMany tap-consumer was bundled with tap@0.3.3, but bundled package wasn't found in unpacked tree
npm WARN deprecated tap-results@0.0.2: This module is not supported. Please use 'tap' instead.
> node-sass@3.2.0 install /home/hgomez/workspace/fielo/raw/node_modules/gulp-sass/node_modules/node-sass
> node scripts/install.js
└── googleapis@1.1.5 (string-template@0.2.1, async@0.9.2, request@2.51.0, gapitoken@0.1.4)
gulp-autoprefixer@2.3.1 node_modules/gulp-autoprefixer
├── object-assign@2.1.1
├── through2@0.6.5 (xtend@4.0.0, readable-stream@1.0.33)
├── vinyl-sourcemaps-apply@0.1.4 (source-map@0.1.43)
├── gulp-util@3.0.5 (array-differ@1.0.0, array-uniq@1.0.2, lodash._reevaluate@3.0.0, beeper@1.1.0, lodash._reescape@3.0.0, lodash._reinterpolate@3.0.0, replace-ext@0.0.1, minimist@1.1.1, vinyl@0.4.6, chalk@1.0.0, lodash.template@3.6.1, multipipe@0.1.2, dateformat@1.0.11)
├── postcss@4.1.11 (js-base64@2.1.8, source-map@0.4.2, es6-promise@2.1.1)
└── autoprefixer-core@5.2.0 (num2fraction@1.1.0, browserslist@0.4.0, caniuse-db@1.0.30000212)
gulp-sass@2.0.1 node_modules/gulp-sass
├── object-assign@2.1.1
├── through2@0.6.5 (xtend@4.0.0, readable-stream@1.0.33)
├── vinyl-sourcemaps-apply@0.1.4 (source-map@0.1.43)
├── gulp-util@3.0.5 (array-differ@1.0.0, array-uniq@1.0.2, beeper@1.1.0, lodash._reescape@3.0.0, lodash._reinterpolate@3.0.0, lodash._reevaluate@3.0.0, replace-ext@0.0.1, minimist@1.1.1, vinyl@0.4.6, lodash.template@3.6.1, chalk@1.0.0, multipipe@0.1.2, dateformat@1.0.11)
└── node-sass@3.2.0 (get-stdin@4.0.1, async-foreach@0.1.3, chalk@1.0.0, nan@1.8.4, mkdirp@0.5.1, meow@3.1.0, glob@5.0.10, npmconf@2.1.2, gaze@0.5.1, request@2.58.0, sass-graph@2.0.0, pangyp@2.2.1)
babel@5.5.8 node_modules/babel
├── slash@1.0.0
├── path-is-absolute@1.0.0
├── fs-readdir-recursive@0.1.2
├── convert-source-map@1.1.1
├── commander@2.8.1 (graceful-readlink@1.0.1)
├── output-file-sync@1.1.1 (xtend@4.0.0, mkdirp@0.5.1)
├── glob@5.0.10 (inherits@2.0.1, once@1.3.2, inflight@1.0.4, minimatch@2.0.8)
├── source-map@0.4.2 (amdefine@0.1.1)
├── chokidar@1.0.3 (arrify@1.0.0, is-glob@1.1.3, glob-parent@1.2.0, async-each@0.1.6, is-binary-path@1.0.1, readdirp@1.3.0, anymatch@1.3.0)
├── lodash@3.9.3
└── babel-core@5.5.8 (strip-json-comments@1.0.2, to-fast-properties@1.0.1, shebang-regex@1.0.0, trim-right@1.0.0, leven@1.0.2, private@0.1.6, globals@6.4.1, estraverse@4.1.0, esutils@2.0.2, home-or-tmp@1.0.0, esquery@0.4.0, js-tokens@1.0.0, line-numbers@0.2.0, debug@2.2.0, is-integer@1.0.4, repeating@1.1.3, chalk@1.0.0, detect-indent@3.0.1, ast-types@0.7.6, minimatch@2.0.8, resolve@1.1.6, bluebird@2.9.30, source-map-support@0.2.10, acorn-jsx@1.0.2, regexpu@1.1.2, regenerator@0.8.28, core-js@0.9.18)
browser-sync@2.7.12 node_modules/browser-sync
├── query-string@2.3.0
├── async-each-series@0.1.1
├── longest@1.0.1
├── emitter-steward@0.0.1
├── ucfirst@0.0.1
├── opn@2.0.0
├── dev-ip@1.0.1
├── pad-left@1.0.2 (repeat-string@1.5.2)
├── ua-parser-js@0.7.7
├── meow@3.1.0 (object-assign@2.1.1, camelcase-keys@1.0.0, minimist@1.1.1, indent-string@1.2.1)
├── portscanner@1.0.0 (async@0.1.15)
├── browser-sync-client@2.2.1 (fresh@0.3.0, etag@1.7.0)
├── foxy@11.0.3 (cookie@0.1.3, http-proxy@1.11.1, lodash.merge@3.3.1)
├── immutable@3.7.3
├── connect@3.3.5 (utils-merge@1.0.0, parseurl@1.3.0, debug@2.1.3, finalhandler@0.3.4)
├── resp-modifier@4.0.2 (minimatch@2.0.8)
├── serve-static@1.9.3 (utils-merge@1.0.0, escape-html@1.0.1, parseurl@1.3.0, send@0.12.3)
├── anymatch@1.3.0 (arrify@1.0.0, micromatch@2.1.6)
├── chokidar@1.0.3 (arrify@1.0.0, path-is-absolute@1.0.0, is-glob@1.1.3, glob-parent@1.2.0, async-each@0.1.6, is-binary-path@1.0.1, readdirp@1.3.0)
├── serve-index@1.7.0 (escape-html@1.0.2, parseurl@1.3.0, batch@0.5.2, http-errors@1.3.1, debug@2.2.0, accepts@1.2.9, mime-types@2.1.1)
├── easy-extender@2.3.1 (lodash@2.4.2)
├── eazy-logger@2.1.2 (tfunk@3.0.1, opt-merger@1.1.0)
├── localtunnel@1.5.1 (debug@0.7.4, optimist@0.3.4, request@2.11.4)
├── lodash@3.9.3
├── socket.io@1.3.5 (debug@2.1.0, has-binary-data@0.1.3, socket.io-adapter@0.3.1, engine.io@1.5.1, socket.io-client@1.3.5, socket.io-parser@2.2.4)
└── browser-sync-ui@0.5.9 (connect-history-api-fallback@0.0.5, angular-touch@1.4.1, angular-sanitize@1.4.1, angular-route@1.4.1, stream-throttle@0.1.3, angular@1.4.1, weinre@2.0.0-pre-I0Z7U9OV)
You're welcome )
Same issue here and rm -rf node_modules && npm install
does not work for me.
Environment info
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.2 LTS
Release: 14.04
Codename: trusty
$ node --version && npm --version
v0.12.6
2.11.2
$ gulp -v
[11:04:25] Requiring external module babel-core/register
[11:04:25] CLI version 3.9.0
[11:04:25] Local version 3.9.0
$ babel -V
5.6.14
Error info:
$ gulp
[11:05:00] Requiring external module babel-core/register
/home/ceram1/workspace/appcore/appcore-js-client/gulpfile.babel.js:1
(function (exports, require, module, __filename, __dirname) { import fs from '
^^^^^^
SyntaxError: Unexpected reserved word
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at normalLoader (/home/ceram1/workspace/appcore/appcore-js-client/node_modules/babel-core/lib/babel/api/register/node.js:200:5)
at Object.require.extensions.(anonymous function) [as .js] (/home/ceram1/workspace/appcore/appcore-js-client/node_modules/babel-core/lib/babel/api/register/node.js:217:7)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Liftoff.handleArguments (/home/ceram1/.npm-packages/lib/node_modules/gulp/bin/gulp.js:116:3)
at Liftoff.<anonymous> (/home/ceram1/.npm-packages/lib/node_modules/gulp/node_modules/liftoff/index.js:192:16)
$ npm ls --depth=0
appcore@0.0.1 /home/ceram1/workspace/appcore/appcore-js-client
├── babel-core@5.6.20
├── babel-eslint@3.1.23
├── babel-plugin-object-assign@1.2.0
├── babel-plugin-react-display-name@1.0.3
├── babelify@6.1.3
├── browser-sync@2.7.13
├── browserify@10.2.6
├── del@1.2.0
├── eslint@0.24.1
├── gulp@3.9.0
├── gulp-autoprefixer@2.3.1
├── gulp-babel@5.1.0
├── gulp-changed@1.2.1
├── gulp-eslint@0.15.0
├── gulp-if@1.2.5
├── gulp-load-plugins@0.10.0
├── gulp-minify-css@1.2.0
├── gulp-sass@2.0.3
├── gulp-size@1.2.3
├── gulp-sourcemaps@1.5.2
├── gulp-uglify@1.2.0
├── react@0.13.3
├── run-sequence@1.1.1
├── sw-precache@2.0.0
├── vinyl-buffer@1.0.0
├── vinyl-source-stream@1.1.0
└── watchify@3.2.3
I found issue, if "gulpfile.babel.js" is not in .babelrc#only, babel does nothing without any message.
$ babel gulpfile.babel.js
Empty..
@ceram1 A better fix would be https://github.com/google/web-starter-kit/pull/727.
I already did it, and actually, I'm not using web-starter-kit. Just my issue was simillar to this.
hi, i have the same issue in
Requiring external module babel-core/register
import fs from 'fs';
^^^^^^
i have tried all the suggested fixes but still not working,
gulp -v
Requiring external module babel-core/register
CLI version 3.9.0
Local version 3.9.0
node -v
v5.2.0
I was having the same issue with the download version of web-starter-kit.
I cloned the git repo instead and that one works just like it is supposed to. Just run npm install
followed by gulp
. Hope this helps.
I had similar errors until I made a .babelrc
file:
$ cat .babelrc
{
"presets": [
"es2015"
]
}
I was getting:
$ gulp watch
[23:03:07] Requiring external module babel-register
/path/to/site/gulpfile.babel.js:2
import gulp from 'gulp';
^^^^^^
SyntaxError: Unexpected token import
@njt1982
Your package.json
should look like:
"devDependencies": {
"babel-cli": "*",
"babel-core": "*",
"babel-preset-es2015": "*"
},
"babel": {
"presets": [
"es2015"
]
}
babel-cli
, babel-core
and babel-preset-es2015
packages are required.
I didn't know you could put the presets in the package conf like that... Is that functionally any different to using the rc file?
I already have the dev dependencies, although I dont have the cli one:
"devDependencies": {
"babel-core": "^6.4.0",
"babel-preset-es2015": "^6.3.13",
....
(this was copies from an existing project which was known to be working).
I'm not a massive fan of using * as the version number as I've been bitted before by stuff randomly upgrading to a new major releasing and trashing my environment, I like relatively strictly pinned tags so any major (or even minor) upgrade is a controlled process by me at a time I chose ;)
I'm not a massive fan of using * as the version number as I've been bitted before by stuff randomly upgrading to a new major releasing and trashing my environment, I like relatively strictly pinned tags so any major (or even minor) upgrade is a controlled process by me at a time I chose ;)
It's not mandatory. package.json
above is an example.
P.S. The current status of this issue is closed. So if you have questions you should post them at Stackoverflow.
My post wasn't a question, it was in case anyone stumbled upon here from Google.
Thanks for the clarification though
:+1:
:D It work for me!!!
check if you indeed have babel installed:
$ npm ls babel If you have it installed, delete the node_modules folder, and rerun your install:
sudo npm install
Tanks @xskif You save my sunday night :p
I had a similar problem while trying to run gulp serve
. I have fixed two errors and am now running without problems. I post this as it may help others.
I set up nodjs on my chromebox running Version 50.0.2661.103 (64-bit) Platform 7978.74.0 (Official Build) stable-channel panther Firmware Google_Panther.4920.24.26. I run Ubunty trusty in a chroot with Crouton, with node v4.4.5 I encountered two errors the first is mentioned above by speeQr. The download version of the Web starter kit 0.6.3 is apparantly not the same as the one on github via clone:
Using the dowload version gives errors such as this:
(trusty)louis@localhost:~/Downloads/MyDoc/testkit2$ gulp serve
[10:46:17] Failed to load external module babel-register
/home/louis/Downloads/MyDoc/testkit2/gulpfile.babel.js:27
import path from 'path';
^^^^^^
SyntaxError: Unexpected reserved word
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at loader (/home/louis/Downloads/MyDoc/testkit2/node_modules/babel-core/node_modules/babel-register/lib/node.js:158:5)
at Object.require.extensions.(anonymous function) [as .js] (/home/louis/Downloads/MyDoc/testkit2/node_modules/babel-core/node_modules/babel-register/lib/node.js:168:7)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Liftoff.handleArguments (/home/louis/.npm-packages/lib/node_modules/gulp/bin/gulp.js:116:3)
at Liftoff.<anonymous> (/home/louis/.npm-packages/lib/node_modules/gulp/node_modules/liftoff/index.js:193:16)
When I fixed this, using a clone of the github repository google/web-starter-kit
, I was stuck with this second error that is mentioned in a thread on stackoverflow. You can find the source here:.
It gives errors such as this:
(trusty)louis@localhost:~/Downloads/MyDoc/testkit$ gulp -v
[10:46:17] Failed to load external module babel-register
[10:46:17] Requiring external module babel-core/register
The solution is from the user: Yeoman on stackoverflow in the same thread. I fixed this by downgrading to gulp version 3.9.0. The downgrade proceeds like this:
npm install -g gulp@3.9.0
Gulp version 3.9.0 is the version that is specified in the dependencies in package.json from the Web starter kit 0.6.3. I am not so familiar with the syntax in package.json, I am guessing ^3.9.0
means 3.9.0 or higher, anybody familiar with that?
Having fixed that too, everything runs fine.
Problem still present on fresh install :(
gulp -v
gives no error but still get import path from 'path';
reserved word error
EDIT : sry about large info ^^'
When pasting large output, PLEASE use the <details>
HTML Element to condense the output in the main view.
The package versions you require are rarely the problem here. Make sure you're running an up-to-date version of node.
$> node -v
v8.1.0
Juste updated node well ... doesn't seems to be the solution
EDIT : tried with both gulp : last version and 3.9.0, no problem with gulp -v
in both case but still got
gulpfile.babel.js:27
import path from 'path';
problem :(
EDIT 2 : Corrected thanks to @joseluisq https://github.com/Ichigochou/WheelEvent/commit/f08d9f567f9be471f8e5ef170c9c3b8b6dba6d3c