Ok so I have a problem installing gulp in my project. I followed the steps on the installation guide but I get a SyntaxError when trying to run their default example.
I just installed gulp with : npm install --global gulp-cli
and npm install --save-dev gulp
I created a file named gulpfile.js at the parent of my project and then added the following code to the file :
var gulp = require('gulp');
gulp.task('default', function() {
// place code for your default task here
});
Then I runed gulp in powershell located at the parent of my project expecting to execute nothing because there is no code in my task but I received the following error :
PS D:\Users\UserName\project> gulp
D:\Users\UserName\project\gulpfile.js:1
(function (exports, require, module, __filename, __dirname) { ��v
^
SyntaxError: Invalid or unexpected token
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:616:28)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at execute (C:\Users\UserName\AppData\Roaming\npm\node_modules\gulp-cli\lib\versioned\^3.7.0\index.js:28:18)
PS D:\Users\UserName\project>
My gulp version after installation are :
[18:56:36] CLI version 2.0.1
[18:56:36] Local version 3.9.1
and my npm version is :
5.6.0
Note that I also tried with actuall task and got the same result
I would like to know what I did wrong or what I need to do to resolve the problem.
As Felix Kling said in the comments, there was strange characters in the beginning of my gulpfile. Indeed, when I copied and pasted the code, it added the hindden caracter for Control-V...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.