SyntaxError:Gulpfile.js中出现意外令牌

时间:2019-09-27 10:47:01

标签: javascript node.js npm node-modules package.json

在我的Gulpfile.js错误部分:

gulp.task('webpack', gulp.series(async () => {
    const option = yargs.argv.release ? "-p" : "-d";
    execSync(`node_modules/webpack-cli/bin/cli.js ${option}`, {
        stdio: [null, process.stdout, process.stderr]
    });
}));

我的package.json:

{
  "scripts": {
    "postinstall": "npm run package-dev",
    "package-dev": "node ./node_modules/gulp/bin/gulp.js",
    "package-release": "node ./node_modules/gulp/bin/gulp.js --release"
  },
  "Dependencies": {
    "@types/applicationinsights-js": "^1.0.5",
    "@types/jquery": "^2.0.41",
    "@types/knockout": "^3.4.40",
    "@types/react": "^16.0.40",
    "@types/react-dom": "^16.9.1",
    "@types/requirejs": "^2.1.28",
    "del": "^3.0.0",
    "gulp": "^4.0.2",
    "gulp-inline-source": "^4.0.0",
    "gulp-sass": "^4.0.2",
    "gulp-tslint": "^8.1.1",
    "office-ui-fabric-react": "^4.5.0",
    "promise-polyfill": "^8.1.0",
    "requirejs": "^2.3.2",
    "ts-loader": "^4.1.0",
    "tslint": "^5.4.3",
    "typescript": "^3.1.6",
    "vss-web-extension-sdk": "^5.141.0",
    "webpack": "^4.26.1",
    "webpack-cli": "^3.1.2"
  },
  "name": "task-group",
  "private": true,
  "version": "0.7.0",
  "dependencies": {
    "@uifabric/utilities": "^7.2.0",
    "react": "^16.9.0"
  },
  "main": "gulpfile.js",
  "keywords": [],
  "author": "",
  "license": "ISC",
  "description": ""
}

我正在运行 npm install ,并收到以下错误消息。

在终端屏幕中:

  

gulp.task('webpack',gulp.series(async()=> {                                              ^       语法错误:意外令牌(           在Object.exports.runInThisContext(vm.js:76:16)           在Module._compile(module.js:542:28)           在Object.Module._extensions..js(module.js:579:10)           在Module.load(module.js:487:32)           在tryModuleLoad(module.js:446:12)           在Function.Module._load(module.js:438:3)           在Module.require(module.js:497:17)           在要求时(internal / module.js:20:19)           执行时(C:\ Users \ Ece \ Documents \ Projects \ Links-Group \ node_modules \ gulp \ node_modules \ gulp-cli \ lib \ versioned \ ^ 4.0.0 \ index       .js:36:18)           在Liftoff.handleArguments(C:\ Users \ Ece \ Documents \ Projects \ Links-Group \ node_modules \ gulp \ node_modules \ gulp-cli \ index.js:2       01:24)

1 个答案:

答案 0 :(得分:0)

我已经运行以下命令分别解决了这个问题。

npm rm -rf节点模块

npm安装