Unexpected token keyword «function», expected punc «,»











up vote
0
down vote

favorite












Here is the error message after I try to run my app




[15:32:01] Starting 'default'...



[15:32:01] Plumber found unhandled error:



GulpUglifyError: unable to minify JavaScript



Caused by: SyntaxError: Unexpected token keyword «function», expected
punc «,»



File: /home/*******/myfile.js Line: 81




my gulp file:



const gulp = require('gulp')
const uglify = require('gulp-uglify')
const babel = require('gulp-babel')
const plumber = require('gulp-plumber')
const del = require('del')

gulp.task('default', ['conf'], () => gulp.src('src/app/**/*.js')
.pipe(plumber())
.pipe(babel())
.pipe(uglify())
.pipe(gulp.dest('dist')))

gulp.task('conf', ['package'], () => gulp.src('./src/conf/*').pipe(gulp.dest('dist/conf')))

gulp.task('package', ['clean'], () => gulp.src(['./package.json']).pipe(gulp.dest('dist/')))

gulp.task('clean', () => del(['dist/**/*']))


If I correctly understand the problem, my code has to be transpiled to es5 by babel, so here is the .babelrc



{
"plugins": [
"transform-class-properties",
"babel-plugin-transform-runtime",
"transform-es2015-shorthand-properties",
["babel-plugin-root-import", {
"rootPathSuffix": "src/app"
}]
],
"presets": ["es2015"]
}


Here is the code from line 81 (where the comments begin) from myfile.js.



export default class Scraper {
// ...
/**
* Converts a html string to a cheerio object
* @param {String} html The html string
* @return {Object} The cheerio object
*/
htmlToDom(html) {
// https://bugs.chromium.org/p/v8/issues/detail?id=2869
// https://github.com/cheeriojs/cheerio/issues/263
if(typeof global.gc === 'function') {
global.gc()
html = (' ' + html).substr(1)
}
return cheerio.load(html)
}

static absolute(location, relative) {
//...
}


First I thought maybe the shorthanded version causing the problem, but I have transform-es2015-shorthand-properties installed, and in an older project I use the very same skeleton, without this plugin.



Update



  "dependencies": {
"babel-plugin-transform-class-properties": "^6.24.1",
"bunyan": "^1.8.10",
"cheerio": "^1.0.0-rc.2",
"colors": "^1.1.2",
"js-yaml": "^3.12.0",
"pg": "^7.4.3",
"puppeteer": "^1.5.0",
"sequelize": "^4.38.0",
"sequelize-connect": "^2.1.1"
},
"devDependencies": {
"ava": "^0.19.1",
"babel-plugin-root-import": "^6.1.0",
"babel-plugin-transform-es2015-shorthand-properties": "^6.24.1",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.7.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-latest": "^6.24.1",
"babel-register": "^6.24.1",
"coveralls": "^2.13.0",
"del": "^2.2.2",
"esdoc": "^0.5.2",
"gulp": "^3.9.1",
"gulp-babel": "^6.1.2",
"gulp-plumber": "^1.1.0",
"gulp-uglify": "^2.1.2",
"mkdir-recursive": "^0.4.0",
"nyc": "^11.2.0",
"sinon": "^2.1.0",
"standard": "^10.0.1",
"wait-on": "^3.2.0"
},









share|improve this question
























  • What version of Babel are you running?
    – Tim Rooke
    Nov 21 at 15:51










  • @TimRooke I updated my question with the package.json
    – user3568719
    Nov 21 at 16:10










  • Your package.json doesn't even list babel-core. Are you sure it's installed? Aside from that, you should asap migrate to Babel 7.
    – connexo
    Nov 21 at 16:21










  • @connexo yes, I have babel-core 6.24.1
    – user3568719
    Nov 21 at 16:56















up vote
0
down vote

favorite












Here is the error message after I try to run my app




[15:32:01] Starting 'default'...



[15:32:01] Plumber found unhandled error:



GulpUglifyError: unable to minify JavaScript



Caused by: SyntaxError: Unexpected token keyword «function», expected
punc «,»



File: /home/*******/myfile.js Line: 81




my gulp file:



const gulp = require('gulp')
const uglify = require('gulp-uglify')
const babel = require('gulp-babel')
const plumber = require('gulp-plumber')
const del = require('del')

gulp.task('default', ['conf'], () => gulp.src('src/app/**/*.js')
.pipe(plumber())
.pipe(babel())
.pipe(uglify())
.pipe(gulp.dest('dist')))

gulp.task('conf', ['package'], () => gulp.src('./src/conf/*').pipe(gulp.dest('dist/conf')))

gulp.task('package', ['clean'], () => gulp.src(['./package.json']).pipe(gulp.dest('dist/')))

gulp.task('clean', () => del(['dist/**/*']))


If I correctly understand the problem, my code has to be transpiled to es5 by babel, so here is the .babelrc



{
"plugins": [
"transform-class-properties",
"babel-plugin-transform-runtime",
"transform-es2015-shorthand-properties",
["babel-plugin-root-import", {
"rootPathSuffix": "src/app"
}]
],
"presets": ["es2015"]
}


Here is the code from line 81 (where the comments begin) from myfile.js.



export default class Scraper {
// ...
/**
* Converts a html string to a cheerio object
* @param {String} html The html string
* @return {Object} The cheerio object
*/
htmlToDom(html) {
// https://bugs.chromium.org/p/v8/issues/detail?id=2869
// https://github.com/cheeriojs/cheerio/issues/263
if(typeof global.gc === 'function') {
global.gc()
html = (' ' + html).substr(1)
}
return cheerio.load(html)
}

static absolute(location, relative) {
//...
}


First I thought maybe the shorthanded version causing the problem, but I have transform-es2015-shorthand-properties installed, and in an older project I use the very same skeleton, without this plugin.



Update



  "dependencies": {
"babel-plugin-transform-class-properties": "^6.24.1",
"bunyan": "^1.8.10",
"cheerio": "^1.0.0-rc.2",
"colors": "^1.1.2",
"js-yaml": "^3.12.0",
"pg": "^7.4.3",
"puppeteer": "^1.5.0",
"sequelize": "^4.38.0",
"sequelize-connect": "^2.1.1"
},
"devDependencies": {
"ava": "^0.19.1",
"babel-plugin-root-import": "^6.1.0",
"babel-plugin-transform-es2015-shorthand-properties": "^6.24.1",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.7.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-latest": "^6.24.1",
"babel-register": "^6.24.1",
"coveralls": "^2.13.0",
"del": "^2.2.2",
"esdoc": "^0.5.2",
"gulp": "^3.9.1",
"gulp-babel": "^6.1.2",
"gulp-plumber": "^1.1.0",
"gulp-uglify": "^2.1.2",
"mkdir-recursive": "^0.4.0",
"nyc": "^11.2.0",
"sinon": "^2.1.0",
"standard": "^10.0.1",
"wait-on": "^3.2.0"
},









share|improve this question
























  • What version of Babel are you running?
    – Tim Rooke
    Nov 21 at 15:51










  • @TimRooke I updated my question with the package.json
    – user3568719
    Nov 21 at 16:10










  • Your package.json doesn't even list babel-core. Are you sure it's installed? Aside from that, you should asap migrate to Babel 7.
    – connexo
    Nov 21 at 16:21










  • @connexo yes, I have babel-core 6.24.1
    – user3568719
    Nov 21 at 16:56













up vote
0
down vote

favorite









up vote
0
down vote

favorite











Here is the error message after I try to run my app




[15:32:01] Starting 'default'...



[15:32:01] Plumber found unhandled error:



GulpUglifyError: unable to minify JavaScript



Caused by: SyntaxError: Unexpected token keyword «function», expected
punc «,»



File: /home/*******/myfile.js Line: 81




my gulp file:



const gulp = require('gulp')
const uglify = require('gulp-uglify')
const babel = require('gulp-babel')
const plumber = require('gulp-plumber')
const del = require('del')

gulp.task('default', ['conf'], () => gulp.src('src/app/**/*.js')
.pipe(plumber())
.pipe(babel())
.pipe(uglify())
.pipe(gulp.dest('dist')))

gulp.task('conf', ['package'], () => gulp.src('./src/conf/*').pipe(gulp.dest('dist/conf')))

gulp.task('package', ['clean'], () => gulp.src(['./package.json']).pipe(gulp.dest('dist/')))

gulp.task('clean', () => del(['dist/**/*']))


If I correctly understand the problem, my code has to be transpiled to es5 by babel, so here is the .babelrc



{
"plugins": [
"transform-class-properties",
"babel-plugin-transform-runtime",
"transform-es2015-shorthand-properties",
["babel-plugin-root-import", {
"rootPathSuffix": "src/app"
}]
],
"presets": ["es2015"]
}


Here is the code from line 81 (where the comments begin) from myfile.js.



export default class Scraper {
// ...
/**
* Converts a html string to a cheerio object
* @param {String} html The html string
* @return {Object} The cheerio object
*/
htmlToDom(html) {
// https://bugs.chromium.org/p/v8/issues/detail?id=2869
// https://github.com/cheeriojs/cheerio/issues/263
if(typeof global.gc === 'function') {
global.gc()
html = (' ' + html).substr(1)
}
return cheerio.load(html)
}

static absolute(location, relative) {
//...
}


First I thought maybe the shorthanded version causing the problem, but I have transform-es2015-shorthand-properties installed, and in an older project I use the very same skeleton, without this plugin.



Update



  "dependencies": {
"babel-plugin-transform-class-properties": "^6.24.1",
"bunyan": "^1.8.10",
"cheerio": "^1.0.0-rc.2",
"colors": "^1.1.2",
"js-yaml": "^3.12.0",
"pg": "^7.4.3",
"puppeteer": "^1.5.0",
"sequelize": "^4.38.0",
"sequelize-connect": "^2.1.1"
},
"devDependencies": {
"ava": "^0.19.1",
"babel-plugin-root-import": "^6.1.0",
"babel-plugin-transform-es2015-shorthand-properties": "^6.24.1",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.7.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-latest": "^6.24.1",
"babel-register": "^6.24.1",
"coveralls": "^2.13.0",
"del": "^2.2.2",
"esdoc": "^0.5.2",
"gulp": "^3.9.1",
"gulp-babel": "^6.1.2",
"gulp-plumber": "^1.1.0",
"gulp-uglify": "^2.1.2",
"mkdir-recursive": "^0.4.0",
"nyc": "^11.2.0",
"sinon": "^2.1.0",
"standard": "^10.0.1",
"wait-on": "^3.2.0"
},









share|improve this question















Here is the error message after I try to run my app




[15:32:01] Starting 'default'...



[15:32:01] Plumber found unhandled error:



GulpUglifyError: unable to minify JavaScript



Caused by: SyntaxError: Unexpected token keyword «function», expected
punc «,»



File: /home/*******/myfile.js Line: 81




my gulp file:



const gulp = require('gulp')
const uglify = require('gulp-uglify')
const babel = require('gulp-babel')
const plumber = require('gulp-plumber')
const del = require('del')

gulp.task('default', ['conf'], () => gulp.src('src/app/**/*.js')
.pipe(plumber())
.pipe(babel())
.pipe(uglify())
.pipe(gulp.dest('dist')))

gulp.task('conf', ['package'], () => gulp.src('./src/conf/*').pipe(gulp.dest('dist/conf')))

gulp.task('package', ['clean'], () => gulp.src(['./package.json']).pipe(gulp.dest('dist/')))

gulp.task('clean', () => del(['dist/**/*']))


If I correctly understand the problem, my code has to be transpiled to es5 by babel, so here is the .babelrc



{
"plugins": [
"transform-class-properties",
"babel-plugin-transform-runtime",
"transform-es2015-shorthand-properties",
["babel-plugin-root-import", {
"rootPathSuffix": "src/app"
}]
],
"presets": ["es2015"]
}


Here is the code from line 81 (where the comments begin) from myfile.js.



export default class Scraper {
// ...
/**
* Converts a html string to a cheerio object
* @param {String} html The html string
* @return {Object} The cheerio object
*/
htmlToDom(html) {
// https://bugs.chromium.org/p/v8/issues/detail?id=2869
// https://github.com/cheeriojs/cheerio/issues/263
if(typeof global.gc === 'function') {
global.gc()
html = (' ' + html).substr(1)
}
return cheerio.load(html)
}

static absolute(location, relative) {
//...
}


First I thought maybe the shorthanded version causing the problem, but I have transform-es2015-shorthand-properties installed, and in an older project I use the very same skeleton, without this plugin.



Update



  "dependencies": {
"babel-plugin-transform-class-properties": "^6.24.1",
"bunyan": "^1.8.10",
"cheerio": "^1.0.0-rc.2",
"colors": "^1.1.2",
"js-yaml": "^3.12.0",
"pg": "^7.4.3",
"puppeteer": "^1.5.0",
"sequelize": "^4.38.0",
"sequelize-connect": "^2.1.1"
},
"devDependencies": {
"ava": "^0.19.1",
"babel-plugin-root-import": "^6.1.0",
"babel-plugin-transform-es2015-shorthand-properties": "^6.24.1",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.7.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-latest": "^6.24.1",
"babel-register": "^6.24.1",
"coveralls": "^2.13.0",
"del": "^2.2.2",
"esdoc": "^0.5.2",
"gulp": "^3.9.1",
"gulp-babel": "^6.1.2",
"gulp-plumber": "^1.1.0",
"gulp-uglify": "^2.1.2",
"mkdir-recursive": "^0.4.0",
"nyc": "^11.2.0",
"sinon": "^2.1.0",
"standard": "^10.0.1",
"wait-on": "^3.2.0"
},






gulp babeljs






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 21 at 16:09

























asked Nov 21 at 14:53









user3568719

473717




473717












  • What version of Babel are you running?
    – Tim Rooke
    Nov 21 at 15:51










  • @TimRooke I updated my question with the package.json
    – user3568719
    Nov 21 at 16:10










  • Your package.json doesn't even list babel-core. Are you sure it's installed? Aside from that, you should asap migrate to Babel 7.
    – connexo
    Nov 21 at 16:21










  • @connexo yes, I have babel-core 6.24.1
    – user3568719
    Nov 21 at 16:56


















  • What version of Babel are you running?
    – Tim Rooke
    Nov 21 at 15:51










  • @TimRooke I updated my question with the package.json
    – user3568719
    Nov 21 at 16:10










  • Your package.json doesn't even list babel-core. Are you sure it's installed? Aside from that, you should asap migrate to Babel 7.
    – connexo
    Nov 21 at 16:21










  • @connexo yes, I have babel-core 6.24.1
    – user3568719
    Nov 21 at 16:56
















What version of Babel are you running?
– Tim Rooke
Nov 21 at 15:51




What version of Babel are you running?
– Tim Rooke
Nov 21 at 15:51












@TimRooke I updated my question with the package.json
– user3568719
Nov 21 at 16:10




@TimRooke I updated my question with the package.json
– user3568719
Nov 21 at 16:10












Your package.json doesn't even list babel-core. Are you sure it's installed? Aside from that, you should asap migrate to Babel 7.
– connexo
Nov 21 at 16:21




Your package.json doesn't even list babel-core. Are you sure it's installed? Aside from that, you should asap migrate to Babel 7.
– connexo
Nov 21 at 16:21












@connexo yes, I have babel-core 6.24.1
– user3568719
Nov 21 at 16:56




@connexo yes, I have babel-core 6.24.1
– user3568719
Nov 21 at 16:56

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53414715%2funexpected-token-keyword-function-expected-punc%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53414715%2funexpected-token-keyword-function-expected-punc%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Berounka

Sphinx de Gizeh

Different font size/position of beamer's navigation symbols template's content depending on regular/plain...