gulp
とbabel
を使って私が設定したプロジェクトがあります。モジュールを作成し、それをインポートすると、ES6からES6に変換されても機能しない場合を除いて、すべてうまく動作しています。私はエラーを取得する:Gulp and Babel:エラー:モジュールが見つかりません
Error: Cannot find module 'hello.js'
at Function.Module._resolveFilename (module.js:440:15)
at Function.Module._load (module.js:388:25)
at Module.require (module.js:468:17)
は、ここに私のgulpfile.babel.js
です:
import gulp from "gulp";
import babel from "gulp-babel"
import concat from "gulp-concat"
const dirs = {
src: "src",
dest: "build"
}
gulp.task("build",() => {
return gulp.src(dirs.src + "/**/*.js")
.pipe(babel())
.pipe(concat("build.js"))
.pipe(gulp.dest(dirs.dest))
});
gulp.task("default", ["build"]);
すべてを1つのファイルに連結され、ビルド時に。 src/
の下で私が持っている:
- app.js
- hellojs
app.js
import hello from './hello.js'
console.log(hello());
hello.js
export default() => {
return 'Hey from hello.js';
};
を基本的に
node ./build/build.js
を呼び出す
npm start
:
そして、私はそうのように実行します。
ES6をES5に連結し、bundle.js
にまだhello.js
の要求が含まれているからです。それは連結されているので、それを見つけることはありません。それは可能ですか?
は、NPMは、インストール、あなたが後に実行されている願っています。右? – Ananthaprakash
'npm install'を実行する必要はありません。私は 'npm i gulp gulp-babel gulp-concat -save'を使ってパッケージをインストールした開発マシンで作業しています – BugHunterUK