Closed ttomdewit closed 8 years ago
I am having a similar issue.
Dependencies
"devDependencies": {
"gulp": "^3.9.1",
"gulp-imagemin": "^3.0.3",
"gulp-svg2png": "^2.0.2"
}
Gulpfile
var gulp = require('gulp'),
svg2png = require('gulp-svg2png'),
imagemin = require('gulp-imagemin');
gulp.task('svg2png', function () {
gulp.src([
'build/images/**/*.svg',
'!build/images/sources',
'!build/images/sources/**/*'
], {base: './'})
.pipe(svg2png())
.pipe(gulp.dest('.'));
});
gulp.task('image', ['svg2png'], function(){
gulp.src([
'./build/images/**/*',
'!build/images/sources',
'!build/images/sources/**/*'
], { base: './build'})
.pipe(imagemin())
.pipe(gulp.dest('./dist'));
});
gulp.task('default', ['image'])
Error
/gulpapp/node_modules/gulp-svg2png/node_modules/svg2png/lib/svg2png.js:28
function getPhantomJSArgs(options = {}) {
^
SyntaxError: Unexpected token =
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:416:10)
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 Object.<anonymous> (/gulpapp/node_modules/gulp-svg2png/index.js:18:15)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
npm -v
returns 2.15.8
node -v
returns v4.4.7
My assumption is that this has to do with svg2png updating and something breaking on that end. Possibly after this: 8150e324 commit?
I worked around it by changing my Dependencies to lock svg2png
to version 3.0.0
"devDependencies": {
"gulp": "^3.9.1",
"gulp-imagemin": "^3.0.3",
"svg2png": "3.0.0",
"gulp-svg2png": "2.0.2"
}
Same error for me 'pngSprite' errored after 6.62 ms
I guess this is related to the use of ES2015 default parameters
. Please check if it works with Node.js ^6.0.0
.
No errors for this package after upgrading Node from v4.5.0
to Node v6.7.0
. I only had to run $ npm rebuild node-sass
once.
I'm on Node 4.2.1, getting the following error on svg2png 4.0.0:
function getPhantomJSArgs(options = {}) {
^
SyntaxError: Unexpected token =
I'm not using gulp, but this seems to be the same issue.
The current long term support (LTS) version of Node is v4.6.1, would it not be wise to ensure the default version of svg2png is compatible with this version of node?
The same from my side. If I change (options = {}) to (options) and inside function added: options = {}; It works perfect. You could change to this way to fix it.
npm i -D svg2png@3.0.1
after
npm i -D gulp-svg2png
helped me
Updating to the latest stable node release fixes this.
Hi all,
I'm getting the following error after using Salita to update svg2png to
gulp-svg2png": "^2.0.2
:npm -v
returns3.10.8
node -v
returnsv4.5.0
The following tasks use svg2png:
And this is my
watch
command:Whenever something changes in
assets/img
it triggers two tasks, namely theimages
task and thesvg
tasks, which in turn triggers thesvg2png
task.