GAumala/gulp-prettier-plugin

TypeError: this is not a typed array.

Closed this issue · 3 comments

I'm trying to run prettier on a couple of files but I'm getting this error:

[11:49:32] Starting 'prettier'...
../node_modules/gulp-prettier-plugin/dist/index.js:74
    outputFile._contents = buffer_1.Buffer.from(transformedCode);

TypeError: this is not a typed array.
    at Function.from (native)
    ...

when running gulp prettier.

My gulp file setup is like this:

var prettier  = require('gulp-prettier-plugin');
gulp.task('prettier', () =>
    gulp
        .src(['.public/library/js/scripts.js', './gulpfile.js'])
        .pipe(
            prettier({
                trailingComma: 'all',
                singleQuote: true,
                bracketSpacing: true,
                useTabs: true,
                printWidth: 100,
            }
        )
    )
    .pipe(gulp.dest(file => file.base))
);

I've updated all my dependencies to be sure that's not it so I'm guessing I'm missing something really obvious!

Hello, what version of Node.js are you using? According to this stack overflow answer Buffer.from() is only available on node 6.0+, however it was backported to node 4.5 and 5.10.

I'm not sure if older versions should be supported. And if they should I'll need carefully figure out an approach that doesn't use deprecated methods on later versions of node.

I just released version 1.0.1 which uses safe-buffer instead of buffer. Please upgrade and let me know if it fixes your problem.

Ah! I had Node 5.8.0 running. I've updated to 1.0.1 and it's working now. Thank you!