1. ホーム
  2. gulp

TypeError: 未定義のプロパティ 'apply' を読み取ることができません。

2022-02-10 13:40:59

1. エラーの内容


Administrator@USER-0GUONPPBHK MINGW64 /g/HBuilderXWork/Vue
$ npm install --save-dev gulp
npm WARN rollback Rolling back [email protected] failed (this is probably ha rmless): EPERM: operation not permitted, scandir 'G:\HBuilderXWork \Vue\node_modu les\fsevents\node_modules'
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fse vents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@ 1.2.9: wanted {"os":"darwin","arch& quot;:"any"} (current: {"os":"win32","arch":"x64"} )

+ [email protected]
added 123 packages from 98 contributors and audited 20796 packages in 55.493s
found 1 moderate severity vulnerability
  run `npm audit fix` to fix them, or `npm audit` for details

Administrator@USER-0GUONPPBHK MINGW64 /g/HBuilderXWork/Vue
$ gulp
[11:17:12] Using gulpfile G:\HBuilderXWork\Vue\gulpfile.js
C:\Users\Administrator.USER-0GUONPPBHK\AppData\Roaming\npm\node_modules\gulp\bin \gulp.js:129
    gulpInst.start.apply(gulpInst, toRun);
                   ^

TypeError: Cannot read property 'apply' of undefined
    at C:\Users\Administrator.USER-0GUONPPBHK\AppData\Roaming\npm\node_modules\g ulp\bin\gulp.js:129:20
    at processTicksAndRejections (internal/process/next_tick.js:74:9)

Administrator@USER-0GUONPPBHK MINGW64 /g/HBuilderXWork/Vue
$ npm install --global gulp
F:\nodejs\node_global\gulp -> F:\nodejs\node_global\node_modules\gulp\bin\gulp.js
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\gulp\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch& quot;:"any"} (current: {"os":"win32","arch":"x64"})

+ [email protected]
added 314 packages from 217 contributors in 57.46s

Administrator@USER-0GUONPPBHK MINGW64 /g/HBuilderXWork/Vue
$ gulp
[11:19:40] Using gulpfile G:\HBuilderXWork\Vue\gulpfile.js
C:\Users\Administrator.USER-0GUONPPBHK\AppData\Roaming\npm\node_modules\gulp\bin\gulp.js:129
    gulpInst.start.apply(gulpInst, toRun);
                   ^

TypeError: Cannot read property 'apply' of undefined
    at C:\Users\Administrator.USER-0GUONPPBHK\AppData\Roaming\npm\node_modules\gulp\bin\gulp.js:129:20
    at processTicksAndRejections (internal/process/next_tick.js:74:9)
    at process.runNextTicks [as _tickCallback] (internal/process/next_tick.js:51:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:777:11)
    at executeUserCode (internal/bootstrap/node.js:499:15)
    at startMainThreadExecution (internal/bootstrap/node.js:436:3)

Administrator@USER-0GUONPPBHK MINGW64 /g/HBuilderXWork/Vue
$ npm i gulp-cli -g
F:\nodejs\node_global\gulp -> F:\nodejs\node_global\node_modules\gulp-cli\bin\gulp.js
+ [email protected]
added 235 packages from 156 contributors in 14.086s

Administrator@USER-0GUONPPBHK MINGW64 /g/HBuilderXWork/Vue
$ gulp
[11:21:09] Using gulpfile G:\HBuilderXWork\Vue\gulpfile.js
C:\Users\Administrator.USER-0GUONPPBHK\AppData\Roaming\npm\node_modules\gulp\bin\gulp.js:129
    gulpInst.start.apply(gulpInst, toRun);
                   ^

TypeError: Cannot read property 'apply' of undefined
    at C:\Users\Administrator.USER-0GUONPPBHK\AppData\Roaming\npm\node_modules\gulp\bin\gulp.js:129:20
    at processTicksAndRejections (internal/process/next_tick.js:74:9)
    at process.runNextTicks [as _tickCallback] (internal/process/next_tick.js:51:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:777:11)
    at executeUserCode (internal/bootstrap/node.js:499:15)
    at startMainThreadExecution (internal/bootstrap/node.js:436:3)

Administrator@USER-0GUONPPBHK MINGW64 /g/HBuilderXWork/Vue
$ npm install --save-dev gulp
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch& quot;:"any"} (current: {"os":"win32","arch":"x64"})

+ [email protected]
added 19 packages from 10 contributors and audited 20796 packages in 16.836s
found 1 moderate severity vulnerability
  run `npm audit fix` to fix them, or `npm audit` for details

Administrator@USER-0GUONPPBHK MINGW64 /g/HBuilderXWork/Vue
$ gulp
[11:24:14] Using gulpfile G:\HBuilderXWork\Vue\gulpfile.js
C:\Users\Administrator.USER-0GUONPPBHK\AppData\Roaming\npm\node_modules\gulp\bin\gulp.js:129
    gulpInst.start.apply(gulpInst, toRun);
                   ^

TypeError: Cannot read property 'apply' of undefined
    at C:\Users\Administrator.USER-0GUONPPBHK\AppData\Roaming\npm\node_modules\gulp\bin\gulp.js:129:20
    at processTicksAndRejections (internal/process/next_tick.js:74:9)
    at process.runNextTicks [as _tickCallback] (internal/process/next_tick.js:51:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:777:11)
    at executeUserCode (internal/bootstrap/node.js:499:15)
    at startMainThreadExecution (internal/bootstrap/node.js:436:3)

Administrator@USER-0GUONPPBHK MINGW64 /g/HBuilderXWork/Vue
$



2. エラーの説明

      vue.jsプロジェクトにgulpをインストールし、gulpfile.jsファイルを作成し、gulpコマンドでコンパイルしたところ、以下のエラーが表示されました。

let gulp = require('gulp');

gulp.task('default',function() {
	console.log('aaaaaa');
});

3. ソリューション

(1) gulpのバージョンの不一致、プロジェクトからgulpを削除し、再度ダウンロードする。

(2) gulp-cliをグローバルにインストールし、gulpとgulp-cliのバージョンが同じであることを確認する。

Administrator@USER-0GUONPPBHK MINGW64 /g/HBuilderXWork/Vue
$ gulp -version
[11:30:36] CLI version 3.9.1
[11:30:36] Local version 4.0.2

Administrator@USER-0GUONPPBHK MINGW64 /g/HBuilderXWork/Vue
$ npm i [email protected] -S
npm WARN deprecated [email protected]: gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util- ca3b1f9f9ac5
npm WARN deprecated [email protected]: please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated [email protected]: please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js
npm WARN deprecated [email protected]: This module relies on Node.js's internals and will break at some point. Do not use it, and update to [email protected].
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch& quot;:"any"} (current: {"os":"win32","arch":"x64"})

+ [email protected]
added 73 packages from 38 contributors, removed 58 packages, updated 11 packages, moved 1 package and audited 15512 packages in 25.431s
found 7 vulnerabilities (1 low, 1 moderate, 5 high)
  run `npm audit fix` to fix them, or `npm audit` for details

Administrator@USER-0GUONPPBHK MINGW64 /g/HBuilderXWork/Vue
$ gulp
[11:32:45] Using gulpfile G:\HBuilderXWork\Vue\gulpfile.js
[11:32:45] Starting 'default'...
aaaaa
[11:32:45] Finished 'default' after 125 μs

Administrator@USER-0GUONPPBHK MINGW64 /g/HBuilderXWork/Vue