Answer the question
In order to leave comments, you need to log in
How to set up gulp-babel to make it work?
I store all folders with my projects in the /home/azat/git/
.
In this case, we are talking about a project that is called, say, project
and stored in the /home/azat/git/project
.
The folder project
contains gulpfile.js
and package.json
.
Here is a small snippet of gulpfile.js :
var babel = require('gulp-babel');
var gulp = require('gulp');
var rename = require("gulp-rename");
gulp.task('jsx', function () {
return gulp.src('src/jsx/*.jsx')
.pipe(rename(function (path) {
path.extname = ".js"
}))
.pipe(babel())
.pipe(gulp.dest('src/js/'));
});
gulp jsx
, the following error is thrown:[email protected]:~/git/project$ gulp jsx
[11:12:36] Using gulpfile ~/git/project/gulpfile.js
[11:12:36] Starting 'jsx'...
events.js:141
throw er; // Unhandled 'error' event
^
SyntaxError: /home/azat/git/package.json: Error while parsing JSON - Unexpected end of input
at Object.parse (native)
at OptionManager.addConfig (/home/azat/git/project/node_modules/babel-core/lib/transformation/file/options/option-manager.js:100:62)
at OptionManager.findConfigs (/home/azat/git/project/node_modules/babel-core/lib/transformation/file/options/option-manager.js:171:32)
at OptionManager.init (/home/azat/git/project/node_modules/babel-core/lib/transformation/file/options/option-manager.js:229:12)
at File.initOptions (/home/azat/git/project/node_modules/babel-core/lib/transformation/file/index.js:147:75)
at new File (/home/azat/git/project/node_modules/babel-core/lib/transformation/file/index.js:137:22)
at Pipeline.transform (/home/azat/git/project/node_modules/babel-core/lib/transformation/pipeline.js:164:16)
at DestroyableTransform._transform (/home/azat/git/project/node_modules/gulp-babel/index.js:30:20)
at DestroyableTransform.Transform._read (/home/azat/git/project/node_modules/gulp-babel/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:172:10)
at DestroyableTransform.Transform._write (/home/azat/git/project/node_modules/gulp-babel/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:160:12)
package.json
a file in the folder above, where it simply does not exist. Well, how, respectively, to solve this problem?
Answer the question
In order to leave comments, you need to log in
I had a problem with regular js. My problem turned out to be that I did not write gulp.src correctly. The gulp-babel instruction on npmjs works great. If it doesn’t work for someone, then you need to carefully check the urls and installed packages
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question