Vue 组件文件仅在 Windows 上构建时存在语法错误



在本地,我的Vue项目运行良好(OSX,Node 9.3,npm 5.6(。但是,当我推送到构建环境(Windows NT 6.3.9600,npm 3.10.8,节点v4.5.0(时,我的构建失败,并且我的.vue文件中有语法错误。我正在使用这里找到的 webpack 样板文件,并对其进行了小调整。

.babelrc

{
  "presets": [
    ["env", {
      "modules": false,
      "targets": {
        "browsers": ["> 1%", "last 2 versions", "not ie <= 8"],
        "node": 4.5
      }
    }],
    "stage-2"
  ],
  "plugins": ["transform-runtime"],
  "env": {
    "test": {
      "presets": ["env", "stage-2"],
      "plugins": [
        "istanbul",
        "babel-plugin-webpack-alias"
      ]
    }
  }
}

包.json

{
  "name": "",
  "version": "1.0.0",
  "description": "",
  "author": "",
  "private": true,
  "scripts": {
    "dev": "node selector-build/dev-server.js",
    "start": "npm run dev",
    "build": "node selector-build/build.js",
    "lint": "eslint --ext .js,.vue src"
  },
  "dependencies": {
    "axios": "0.17.0",
    "gsap": "1.20.3",
    "lodash": "4.17.4",
    "scrollmagic": "2.0.5",
    "slick-carousel": "1.8.1",
    "slugify": "1.2.1",
    "style-loader": "0.19.0",
    "vue": "2.5.13",
    "vue-router": "3.0.1"
  },
  "devDependencies": {
    "autoprefixer": "7.1.2",
    "babel-core": "6.22.1",
    "babel-eslint": "7.1.1",
    "babel-loader": "7.1.1",
    "babel-plugin-transform-runtime": "6.22.0",
    "babel-plugin-webpack-alias": "2.1.2",
    "babel-preset-env": "1.3.2",
    "babel-preset-stage-2": "6.22.0",
    "babel-register": "6.22.0",
    "chalk": "2.0.1",
    "connect-history-api-fallback": "1.3.0",
    "copy-webpack-plugin": "4.0.1",
    "cross-env": "^3.1.4",
    "css-loader": "0.28.0",
    "eslint": "3.19.0",
    "eslint-friendly-formatter": "3.0.0",
    "eslint-loader": "1.7.1",
    "eslint-plugin-html": "3.0.0",
    "eventsource-polyfill": "0.9.6",
    "express": "4.14.1",
    "extract-text-webpack-plugin": "3.0.0",
    "file-loader": "1.1.4",
    "friendly-errors-webpack-plugin": "1.6.1",
    "html-webpack-plugin": "2.30.1",
    "http-proxy-middleware": "0.17.3",
    "jquery": "3.2.1",
    "node-sass": "4.7.2",
    "opn": "5.1.0",
    "optimize-css-assets-webpack-plugin": "3.2.0",
    "ora": "1.2.0",
    "portfinder": "1.0.13",
    "rimraf": "2.6.0",
    "sass-loader": "6.0.6",
    "semver": "5.3.0",
    "shelljs": "0.7.6",
    "url-loader": "0.5.8",
    "vue-loader": "13.7.0",
    "vue-style-loader": "3.0.1",
    "vue-template-compiler": "2.5.13",
    "webpack": "3.6.0",
    "webpack-bundle-analyzer": "2.9.0",
    "webpack-dev-middleware": "1.12.0",
    "webpack-hot-middleware": "2.18.2",
    "webpack-merge": "4.1.0"
  },
  "engines": {
    "node": ">= 4.0.0",
    "npm": ">= 3.0.0"
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not ie <= 8"
  ]
}

错误摘要

2018-01-10T22:29:56.0054806Z [1m[31mERROR in ./src/App.vue
2018-01-10T22:29:56.0054806Z Module build failed: SyntaxError: Unexpected token {
2018-01-10T22:29:56.0054806Z     at exports.runInThisContext (vm.js:53:16)
2018-01-10T22:29:56.0054806Z     at Module._compile (module.js:373:25)
2018-01-10T22:29:56.0054806Z     at Object.Module._extensions..js (module.js:416:10)
2018-01-10T22:29:56.0054806Z     at Module.load (module.js:343:32)
2018-01-10T22:29:56.0054806Z     at Function.Module._load (module.js:300:12)
2018-01-10T22:29:56.0054806Z     at Module.require (module.js:353:17)
2018-01-10T22:29:56.0054806Z     at require (internal/module.js:12:17)
2018-01-10T22:29:56.0054806Z     at Object.<anonymous> (F:BA12ssrcprojectNameprojectNameprojectName.Web.UiAreasprojectNameAssetsappsselectornode_modulesvue-loaderindex.js:1:80)
2018-01-10T22:29:56.0054806Z     at Module._compile (module.js:409:26)
2018-01-10T22:29:56.0054806Z     at Object.Module._extensions..js (module.js:416:10)
2018-01-10T22:29:56.0054806Z     at Module.load (module.js:343:32)
2018-01-10T22:29:56.0054806Z     at Function.Module._load (module.js:300:12)
2018-01-10T22:29:56.0054806Z     at Module.require (module.js:353:17)
2018-01-10T22:29:56.0054806Z     at require (internal/module.js:12:17)
2018-01-10T22:29:56.0054806Z     at loadLoader (F:BA12ssrcprojectNameprojectNameprojectName.Web.UiAreasprojectNameAssetsappsselectornode_modulesloader-runnerlibloadLoader.js:13:17)
2018-01-10T22:29:56.0054806Z     at iteratePitchingLoaders (F:BA12ssrcprojectNameprojectNameprojectName.Web.UiAreasprojectNameAssetsappsselectornode_modulesloader-runnerlibLoaderRunner.js:169:2)
2018-01-10T22:29:56.0054806Z     at runLoaders (F:BA12ssrcprojectNameprojectNameprojectName.Web.UiAreasprojectNameAssetsappsselectornode_modulesloader-runnerlibLoaderRunner.js:362:2)
2018-01-10T22:29:56.0054806Z     at NormalModule.doBuild (F:BA12ssrcprojectNameprojectNameprojectName.Web.UiAreasprojectNameAssetsappsselectornode_moduleswebpacklibNormalModule.js:182:3)
2018-01-10T22:29:56.0054806Z     at NormalModule.build (F:BA12ssrcprojectNameprojectNameprojectName.Web.UiAreasprojectNameAssetsappsselectornode_moduleswebpacklibNormalModule.js:275:15)
2018-01-10T22:29:56.0054806Z     at Compilation.buildModule (F:BA12ssrcprojectNameprojectNameprojectName.Web.UiAreasprojectNameAssetsappsselectornode_moduleswebpacklibCompilation.js:149:10)
2018-01-10T22:29:56.0054806Z     at factoryCallback (F:BA12ssrcprojectNameprojectNameprojectName.Web.UiAreasprojectNameAssetsappsselectornode_moduleswebpacklibCompilation.js:337:12)
2018-01-10T22:29:56.0054806Z     at F:BA12ssrcprojectNameprojectNameprojectName.Web.UiAreasprojectNameAssetsappsselectornode_moduleswebpacklibNormalModuleFactory.js:241:5
2018-01-10T22:29:56.0054806Z  @ ./src/main.js 4:0-24[39m[22m
2018-01-10T22:29:56.0054806Z 
2018-01-10T22:29:56.0054806Z [1m[31mERROR in ./src/components/views/Slide.vue
2018-01-10T22:29:56.0054806Z Module build failed: SyntaxError: Unexpected token {
2018-01-10T22:29:56.0054806Z     at exports.runInThisContext (vm.js:53:16)
2018-01-10T22:29:56.0054806Z     at Module._compile (module.js:373:25)
2018-01-10T22:29:56.0054806Z     at Object.Module._extensions..js (module.js:416:10)
2018-01-10T22:29:56.0054806Z     at Module.load (module.js:343:32)
2018-01-10T22:29:56.0054806Z     at Function.Module._load (module.js:300:12)
2018-01-10T22:29:56.0054806Z     at Module.require (module.js:353:17)
2018-01-10T22:29:56.0054806Z     at require (internal/module.js:12:17)
2018-01-10T22:29:56.0054806Z     at Object.<anonymous> (F:BA12ssrcprojectNameprojectNameprojectName.Web.UiAreasprojectNameAssetsappsselectornode_modulesvue-loaderindex.js:1:80)
2018-01-10T22:29:56.0054806Z     at Module._compile (module.js:409:26)
2018-01-10T22:29:56.0054806Z     at Object.Module._extensions..js (module.js:416:10)
2018-01-10T22:29:56.0054806Z     at Module.load (module.js:343:32)
2018-01-10T22:29:56.0054806Z     at Function.Module._load (module.js:300:12)
2018-01-10T22:29:56.0054806Z     at Module.require (module.js:353:17)
2018-01-10T22:29:56.0054806Z     at require (internal/module.js:12:17)
2018-01-10T22:29:56.0054806Z     at loadLoader (F:BA12ssrcprojectNameprojectNameprojectName.Web.UiAreasprojectNameAssetsappsselectornode_modulesloader-runnerlibloadLoader.js:13:17)
2018-01-10T22:29:56.0054806Z     at iteratePitchingLoaders (F:BA12ssrcprojectNameprojectNameprojectName.Web.UiAreasprojectNameAssetsappsselectornode_modulesloader-runnerlibLoaderRunner.js:169:2)
2018-01-10T22:29:56.0054806Z     at runLoaders (F:BA12ssrcprojectNameprojectNameprojectName.Web.UiAreasprojectNameAssetsappsselectornode_modulesloader-runnerlibLoaderRunner.js:362:2)
2018-01-10T22:29:56.0054806Z     at NormalModule.doBuild (F:BA12ssrcprojectNameprojectNameprojectName.Web.UiAreasprojectNameAssetsappsselectornode_moduleswebpacklibNormalModule.js:182:3)
2018-01-10T22:29:56.0054806Z     at NormalModule.build (F:BA12ssrcprojectNameprojectNameprojectName.Web.UiAreasprojectNameAssetsappsselectornode_moduleswebpacklibNormalModule.js:275:15)
2018-01-10T22:29:56.0054806Z     at Compilation.buildModule (F:BA12ssrcprojectNameprojectNameprojectName.Web.UiAreasprojectNameAssetsappsselectornode_moduleswebpacklibCompilation.js:149:10)
2018-01-10T22:29:56.0054806Z     at factoryCallback (F:BA12ssrcprojectNameprojectNameprojectName.Web.UiAreasprojectNameAssetsappsselectornode_moduleswebpacklibCompilation.js:337:12)
2018-01-10T22:29:56.0054806Z     at F:BA12ssrcprojectNameprojectNameprojectName.Web.UiAreasprojectNameAssetsappsselectornode_moduleswebpacklibNormalModuleFactory.js:241:5
2018-01-10T22:29:56.0054806Z  @ ./src/Bus.js 5:0-45
2018-01-10T22:29:56.0054806Z  @ ./src/main.js[39m[22m
2018-01-10T22:29:56.0054806Z 
2018-01-10T22:29:56.0054806Z [1m[31mERROR in ./src/components/views/Landing.vue
2018-01-10T22:29:56.0054806Z Module build failed: SyntaxError: Unexpected token {
2018-01-10T22:29:56.0054806Z     at exports.runInThisContext (vm.js:53:16)
2018-01-10T22:29:56.0054806Z     at Module._compile (module.js:373:25)
2018-01-10T22:29:56.0054806Z     at Object.Module._extensions..js (module.js:416:10)
2018-01-10T22:29:56.0054806Z     at Module.load (module.js:343:32)
2018-01-10T22:29:56.0054806Z     at Function.Module._load (module.js:300:12)
2018-01-10T22:29:56.0054806Z     at Module.require (module.js:353:17)
2018-01-10T22:29:56.0054806Z     at require (internal/module.js:12:17)
2018-01-10T22:29:56.0054806Z     at Object.<anonymous> (F:BA12ssrcprojectNameprojectNameprojectName.Web.UiAreasprojectNameAssetsappsselectornode_modulesvue-loaderindex.js:1:80)
2018-01-10T22:29:56.0054806Z     at Module._compile (module.js:409:26)
2018-01-10T22:29:56.0054806Z     at Object.Module._extensions..js (module.js:416:10)
2018-01-10T22:29:56.0054806Z     at Module.load (module.js:343:32)
2018-01-10T22:29:56.0054806Z     at Function.Module._load (module.js:300:12)
2018-01-10T22:29:56.0054806Z     at Module.require (module.js:353:17)
2018-01-10T22:29:56.0054806Z     at require (internal/module.js:12:17)
2018-01-10T22:29:56.0054806Z     at loadLoader (F:BA12ssrcprojectNameprojectNameprojectName.Web.UiAreasprojectNameAssetsappsselectornode_modulesloader-runnerlibloadLoader.js:13:17)
2018-01-10T22:29:56.0054806Z     at iteratePitchingLoaders (F:BA12ssrcprojectNameprojectNameprojectName.Web.UiAreasprojectNameAssetsappsselectornode_modulesloader-runnerlibLoaderRunner.js:169:2)
2018-01-10T22:29:56.0054806Z     at runLoaders (F:BA12ssrcprojectNameprojectNameprojectName.Web.UiAreasprojectNameAssetsappsselectornode_modulesloader-runnerlibLoaderRunner.js:362:2)
2018-01-10T22:29:56.0054806Z     at NormalModule.doBuild (F:BA12ssrcprojectNameprojectNameprojectName.Web.UiAreasprojectNameAssetsappsselectornode_moduleswebpacklibNormalModule.js:182:3)
2018-01-10T22:29:56.0054806Z     at NormalModule.build (F:BA12ssrcprojectNameprojectNameprojectName.Web.UiAreasprojectNameAssetsappsselectornode_moduleswebpacklibNormalModule.js:275:15)
2018-01-10T22:29:56.0054806Z     at Compilation.buildModule (F:BA12ssrcprojectNameprojectNameprojectName.Web.UiAreasprojectNameAssetsappsselectornode_moduleswebpacklibCompilation.js:149:10)
2018-01-10T22:29:56.0054806Z     at factoryCallback (F:BA12ssrcprojectNameprojectNameprojectName.Web.UiAreasprojectNameAssetsappsselectornode_moduleswebpacklibCompilation.js:337:12)
2018-01-10T22:29:56.0054806Z     at F:BA12ssrcprojectNameprojectNameprojectName.Web.UiAreasprojectNameAssetsappsselectornode_moduleswebpacklibNormalModuleFactory.js:241:5
2018-01-10T22:29:56.0054806Z  @ ./src/router/index.js 3:0-49
2018-01-10T22:29:56.0054806Z  @ ./src/main.js[39m[22m
2018-01-10T22:29:56.0054806Z 
2018-01-10T22:29:56.0054806Z [1m[31mERROR in ./src/components/views/Recommendations.vue
2018-01-10T22:29:56.0054806Z Module build failed: SyntaxError: Unexpected token {
2018-01-10T22:29:56.0054806Z     at exports.runInThisContext (vm.js:53:16)
2018-01-10T22:29:56.0054806Z     at Module._compile (module.js:373:25)
2018-01-10T22:29:56.0054806Z     at Object.Module._extensions..js (module.js:416:10)
2018-01-10T22:29:56.0054806Z     at Module.load (module.js:343:32)
2018-01-10T22:29:56.0054806Z     at Function.Module._load (module.js:300:12)
2018-01-10T22:29:56.0054806Z     at Module.require (module.js:353:17)
2018-01-10T22:29:56.0054806Z     at require (internal/module.js:12:17)
2018-01-10T22:29:56.0054806Z     at Object.<anonymous> (F:BA12ssrcprojectNameprojectNameprojectName.Web.UiAreasprojectNameAssetsappsselectornode_modulesvue-loaderindex.js:1:80)
2018-01-10T22:29:56.0054806Z     at Module._compile (module.js:409:26)
2018-01-10T22:29:56.0054806Z     at Object.Module._extensions..js (module.js:416:10)
2018-01-10T22:29:56.0054806Z     at Module.load (module.js:343:32)
2018-01-10T22:29:56.0054806Z     at Function.Module._load (module.js:300:12)
2018-01-10T22:29:56.0054806Z     at Module.require (module.js:353:17)
2018-01-10T22:29:56.0054806Z     at require (internal/module.js:12:17)
2018-01-10T22:29:56.0054806Z     at loadLoader (F:BA12ssrcprojectNameprojectNameprojectName.Web.UiAreasprojectNameAssetsappsselectornode_modulesloader-runnerlibloadLoader.js:13:17)
2018-01-10T22:29:56.0054806Z     at iteratePitchingLoaders (F:BA12ssrcprojectNameprojectNameprojectName.Web.UiAreasprojectNameAssetsappsselectornode_modulesloader-runnerlibLoaderRunner.js:169:2)
2018-01-10T22:29:56.0054806Z     at runLoaders (F:BA12ssrcprojectNameprojectNameprojectName.Web.UiAreasprojectNameAssetsappsselectornode_modulesloader-runnerlibLoaderRunner.js:362:2)
2018-01-10T22:29:56.0054806Z     at NormalModule.doBuild (F:BA12ssrcprojectNameprojectNameprojectName.Web.UiAreasprojectNameAssetsappsselectornode_moduleswebpacklibNormalModule.js:182:3)
2018-01-10T22:29:56.0054806Z     at NormalModule.build (F:BA12ssrcprojectNameprojectNameprojectName.Web.UiAreasprojectNameAssetsappsselectornode_moduleswebpacklibNormalModule.js:275:15)
2018-01-10T22:29:56.0054806Z     at Compilation.buildModule (F:BA12ssrcprojectNameprojectNameprojectName.Web.UiAreasprojectNameAssetsappsselectornode_moduleswebpacklibCompilation.js:149:10)
2018-01-10T22:29:56.0054806Z     at factoryCallback (F:BA12ssrcprojectNameprojectNameprojectName.Web.UiAreasprojectNameAssetsappsselectornode_moduleswebpacklibCompilation.js:337:12)
2018-01-10T22:29:56.0054806Z     at F:BA12ssrcprojectNameprojectNameprojectName.Web.UiAreasprojectNameAssetsappsselectornode_moduleswebpacklibNormalModuleFactory.js:241:5
2018-01-10T22:29:56.0054806Z  @ ./src/router/index.js 4:0-65
2018-01-10T22:29:56.0054806Z  @ ./src/main.js[39m[22m
2018-01-10T22:29:56.0054806Z 
2018-01-10T22:29:56.0054806Z [1m[31mERROR in ./src/components/views/notFound.vue
2018-01-10T22:29:56.0054806Z Module build failed: SyntaxError: Unexpected token {
2018-01-10T22:29:56.0054806Z     at exports.runInThisContext (vm.js:53:16)
2018-01-10T22:29:56.0054806Z     at Module._compile (module.js:373:25)
2018-01-10T22:29:56.0054806Z     at Object.Module._extensions..js (module.js:416:10)
2018-01-10T22:29:56.0054806Z     at Module.load (module.js:343:32)
2018-01-10T22:29:56.0054806Z     at Function.Module._load (module.js:300:12)
2018-01-10T22:29:56.0054806Z     at Module.require (module.js:353:17)
2018-01-10T22:29:56.0054806Z     at require (internal/module.js:12:17)
2018-01-10T22:29:56.0054806Z     at Object.<anonymous> (F:BA12ssrcprojectNameprojectNameprojectName.Web.UiAreasprojectNameAssetsappsselectornode_modulesvue-loaderindex.js:1:80)
2018-01-10T22:29:56.0054806Z     at Module._compile (module.js:409:26)
2018-01-10T22:29:56.0054806Z     at Object.Module._extensions..js (module.js:416:10)
2018-01-10T22:29:56.0054806Z     at Module.load (module.js:343:32)
2018-01-10T22:29:56.0054806Z     at Function.Module._load (module.js:300:12)
2018-01-10T22:29:56.0054806Z     at Module.require (module.js:353:17)
2018-01-10T22:29:56.0054806Z     at require (internal/module.js:12:17)
2018-01-10T22:29:56.0054806Z     at loadLoader (F:BA12ssrcprojectNameprojectNameprojectName.Web.UiAreasprojectNameAssetsappsselectornode_modulesloader-runnerlibloadLoader.js:13:17)
2018-01-10T22:29:56.0054806Z     at iteratePitchingLoaders (F:BA12ssrcprojectNameprojectNameprojectName.Web.UiAreasprojectNameAssetsappsselectornode_modulesloader-runnerlibLoaderRunner.js:169:2)
2018-01-10T22:29:56.0054806Z     at runLoaders (F:BA12ssrcprojectNameprojectNameprojectName.Web.UiAreasprojectNameAssetsappsselectornode_modulesloader-runnerlibLoaderRunner.js:362:2)
2018-01-10T22:29:56.0054806Z     at NormalModule.doBuild (F:BA12ssrcprojectNameprojectNameprojectName.Web.UiAreasprojectNameAssetsappsselectornode_moduleswebpacklibNormalModule.js:182:3)
2018-01-10T22:29:56.0054806Z     at NormalModule.build (F:BA12ssrcprojectNameprojectNameprojectName.Web.UiAreasprojectNameAssetsappsselectornode_moduleswebpacklibNormalModule.js:275:15)
2018-01-10T22:29:56.0054806Z     at Compilation.buildModule (F:BA12ssrcprojectNameprojectNameprojectName.Web.UiAreasprojectNameAssetsappsselectornode_moduleswebpacklibCompilation.js:149:10)
2018-01-10T22:29:56.0054806Z     at factoryCallback (F:BA12ssrcprojectNameprojectNameprojectName.Web.UiAreasprojectNameAssetsappsselectornode_moduleswebpacklibCompilation.js:337:12)
2018-01-10T22:29:56.0054806Z     at F:BA12ssrcprojectNameprojectNameprojectName.Web.UiAreasprojectNameAssetsappsselectornode_moduleswebpacklibNormalModuleFactory.js:241:5
2018-01-10T22:29:56.0054806Z  @ ./src/router/index.js 6:0-51
2018-01-10T22:29:56.0054806Z  @ ./src/main.js[39m[22m
2018-01-10T22:29:56.0054806Z 
2018-01-10T22:29:56.0054806Z   Build failed with errors.

它似乎只在我的 .vue 组件文件中出错,但同样,仅在此 Windows 环境中出错。任何想法或建议将不胜感激。谢谢。

事实证明,vue-loader 在 >13.0.1 版本中效果不佳。切换到13.0.1使我的构建成功。

Webpack vue-loader 为单页 .vue 组件提供"意外标记 {">

相关内容

  • 没有找到相关文章

最新更新