- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 Vue.js 项目,它直到几分钟前才正常工作。当 npm run build
时,我正在尝试添加一个新的小功能。停止工作,使用 Syntax Error
你在下面看到。我花了一些时间阅读它,但在我看来,没有关于 Unexpected token
的位置的线索。实际上是,除了它在 App.vue 中。
我怀疑我可能最终可以通过只取出代码来让它工作,直到我弄清楚它正在窒息,但是处理这些错误消息的首选方法是什么?它们似乎没有帮助,每次我收到 Syntax Error
时都会拉出代码这将比立即知道错误在哪里要慢得多。
| building for production...
Starting to optimize CSS...
Processing css/app.b78de1b1e52d045850f3f8ef25eab789.css...
Processed css/app.b78de1b1e52d045850f3f8ef25eab789.css, before: 2077, after: 2009, ratio: 96.73%
Hash: 463db738399a4df0bc89
Version: webpack 2.6.1
Time: 7211ms
Asset Size Chunks Chunk Names
js/app.46d986e313fa2c015cd0.js 5.62 kB 0 [emitted] app
js/vendor.bf7e840e23d2fcdbebe0.js 141 kB 1 [emitted] vendor
js/manifest.c323c0be7462a1c8da87.js 1.51 kB 2 [emitted] manifest
css/app.b78de1b1e52d045850f3f8ef25eab789.css 2.01 kB 0 [emitted] app
js/app.46d986e313fa2c015cd0.js.map 26 kB 0 [emitted] app
css/app.b78de1b1e52d045850f3f8ef25eab789.css.map 4.13 kB 0 [emitted] app
js/vendor.bf7e840e23d2fcdbebe0.js.map 974 kB 1 [emitted] vendor
js/manifest.c323c0be7462a1c8da87.js.map 14.6 kB 2 [emitted] manifest
..\..\templates\app.html 598 bytes [emitted]
ERROR in ./~/vue-loader/lib/template-compiler?{"id":"data-v-59c95520"}!./~/vue-loader/lib/selector.js?type=template&index=0!./src/App.vue
Module build failed: SyntaxError: Unexpected token (72:13)
at Parser.pp$4.raise (C:\path_to_project\client\node_modules\vue-template-es2015-compiler\buble.js:2231:15)
at Parser.pp.unexpected (C:\path_to_project\client\node_modules\vue-template-es2015-compiler\buble.js:613:10)
at Parser.pp.expect (C:\path_to_project\client\node_modules\vue-template-es2015-compiler\buble.js:607:28)
at Parser.parseObj (C:\path_to_project\client\node_modules\vue-template-es2015-compiler\buble.js:3871:16)
at Parser.pp$3.parseExprAtom (C:\path_to_project\client\node_modules\vue-template-es2015-compiler\buble.js:1815:19)
at Parser.parseExprAtom (C:\path_to_project\client\node_modules\vue-template-es2015-compiler\buble.js:3800:24)
at Parser.pp$3.parseExprSubscripts (C:\path_to_project\client\node_modules\vue-template-es2015-compiler\buble.js:1725:21)
at Parser.pp$3.parseMaybeUnary (C:\path_to_project\client\node_modules\vue-template-es2015-compiler\buble.js:1702:19)
at Parser.pp$3.parseExprOps (C:\path_to_project\client\node_modules\vue-template-es2015-compiler\buble.js:1647:21)
at Parser.pp$3.parseMaybeConditional (C:\path_to_project\client\node_modules\vue-template-es2015-compiler\buble.js:1630:21)
at Parser.pp$3.parseMaybeAssign (C:\path_to_project\client\node_modules\vue-template-es2015-compiler\buble.js:1607:21)
at Parser.pp$3.parsePropertyValue (C:\path_to_project\client\node_modules\vue-template-es2015-compiler\buble.js:2008:89)
at Parser.parseObj (C:\path_to_project\client\node_modules\vue-template-es2015-compiler\buble.js:3895:14)
at Parser.pp$3.parseExprAtom (C:\path_to_project\client\node_modules\vue-template-es2015-compiler\buble.js:1815:19)
at Parser.parseExprAtom (C:\path_to_project\client\node_modules\vue-template-es2015-compiler\buble.js:3800:24)
at Parser.pp$3.parseExprSubscripts (C:\path_to_project\client\node_modules\vue-template-es2015-compiler\buble.js:1725:21)
at Parser.pp$3.parseMaybeUnary (C:\path_to_project\client\node_modules\vue-template-es2015-compiler\buble.js:1702:19)
at Parser.pp$3.parseExprOps (C:\path_to_project\client\node_modules\vue-template-es2015-compiler\buble.js:1647:21)
at Parser.pp$3.parseMaybeConditional (C:\path_to_project\client\node_modules\vue-template-es2015-compiler\buble.js:1630:21)
at Parser.pp$3.parseMaybeAssign (C:\path_to_project\client\node_modules\vue-template-es2015-compiler\buble.js:1607:21)
at Parser.pp$3.parseExprList (C:\path_to_project\client\node_modules\vue-template-es2015-compiler\buble.js:2175:22)
at Parser.pp$3.parseSubscripts (C:\path_to_project\client\node_modules\vue-template-es2015-compiler\buble.js:1751:35)
@ ./src/App.vue 8:2-170
@ ./src/main.js
<template>
<div id="app">
<div id="toolbar" v-on-clickaway="disableSongToolbar">
<div id="toolbar__left">
<a class="ui-text toolbar__option" href="/">Rhymecraft</a>
<div class="ui-text toolbar__option"
:class="{ toolbar__option_active: songToolbarActive }"
@click="toggleSongToolbarDropdown()">
Song
</div>
<div class="ui-text toolbar__option">Line</div>
<div class="ui-text toolbar__option">Help</div>
</div>
<div id="toolbar__right">
<a class="ui-text toolbar__option" href="/logout">Log out</a>
</div>
</div>
<div id="toolbar-dropdowns">
<div id="toolbar-dropdowns__song" v-show="songToolbarActive">
<div class="ui-text toolbar__option toolbar-dropdown-option toolbar-dropdown-not-last-option"
@click="createNewSong">Create new song</div>
<div class="ui-text toolbar__option toolbar-dropdown-option"
@click="displayListOfUsersSongs">Load song</div>
<div class="ui-text toolbar__option toolbar-dropdown-option"
v-if="song.hasOwnProperty('id')"
@click="displayConfirmDeleteSong = true">Delete current song</div>
</div>
</div>
<div id="modals" :class="{ modals-active: modalActive }">
<div id="song-loader" v-show="displaySongLoader">
<div id="song-loader-header" class="ui-text">Load Song</div>
<div class="ui-text song-loader__item song-loader__selectable-item" v-for="song in songs" @click="loadSong(song.id)">{{ song.name }}</div>
<div class="ui-text song-loader__item" v-if="songs.length === 0 || !songs[0].hasOwnProperty('id')">You do not have any songs.</div>
<div id="song-loader__cancel" class="ui-text" @click="displaySongLoader = false">Cancel</div>
</div>
<div id="confirm-delete-song" v-show="displayConfirmDeleteSong">
<div id="confirm-delete-song__header" class="ui-text">Delete Song</div>
<div id="confirm-delete-song__cancel" class="ui-text" @click="displayConfirmDeleteSong = false">Cancel</div>
<div id="confirm-delete-song__spacer"></div>
<div id="confirm-delete-song__confirm" class="ui-text" @click="deleteCurrentSong">Confirm</div>
</div>
</div>
<div id="song-area">
<div id="song">
<div v-for="line in song.lines" class="song-line">
<div v-for="spanOfTime in line.spansOfTime"
class="ui-text span-of-time span-of-time--4"
:id="spanOfTime.id"
@click="currentlySelectedSpanOfTime = spanOfTime.id; console.log(spanOfTime.id)"> </div>
</div>
</div>
</div>
<router-view></router-view>
</div>
</template>
<script>
import { mixin as clickaway } from 'vue-clickaway'
export default {
name: 'app',
mixins: [ clickaway ],
data: function () {
return {
songToolbarActive: false,
displaySongLoader: false,
song: [],
songs: [],
displayConfirmDeleteSong: false,
currentlySelectedSpanOfTime: -1
}
},
computed: {
modalActive: function () {
if (this.displaySongLoader) {
return true
}
}
},
methods: {
toggleSongToolbarDropdown: function () {
this.songToolbarActive = !this.songToolbarActive
},
disableSongToolbar: function () {
if (this.songToolbarActive) {
this.songToolbarActive = false
}
},
createNewSong: function () {
this.$http.post('/song/create').then(response => {
this.song = response.data.song
}, response => {
// error callback
})
},
displayListOfUsersSongs: function () {
this.$http.get('/songs').then(response => {
this.songs = response.data.songs
this.displaySongLoader = true
}, response => {
// error callback
})
},
loadSong: function (songId) {
this.displaySongLoader = false
this.$http.get('/song/' + songId).then(response => {
this.song = response.data.song
}, response => {
this.song = []
})
},
deleteCurrentSong: function () {
this.displayConfirmDeleteSong = false
this.$http.post('/song/' + this.song.id + '/delete').then(response => {
this.song = []
}, response => {
})
}
}
}
</script>
<style>
html, body {
height: 100%;
}
div#modals {
position: absolute;
text-align: center;
width: 100%;
height: 100%;
display: flex;
}
div.modals-active {
z-index: 1;
}
div#song-loader {
width: 300px;
display: flex;
flex-direction: column;
justify-content: center;
margin: auto;
border: 1px solid rgb(85, 85, 85);
}
div#song-loader-header {
padding: 5px 0px;
background-color:rgb(60,63,65);
}
div.song-loader__item {
background-color: beige;
padding: 10px;
color: rgb(60, 60, 60);
}
div.song-loader__selectable-item:hover {
background-color: rgb(230, 230, 190);
}
div#song-loader__cancel {
padding: 5px 0px;
}
div#song-area {
height: 100%;
}
div#song {
width: 608px;
height: 30px;
margin: auto;
display: block;
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
}
div.span-of-time {
background-color: white;
min-height: 29px;
display: inline-block;
border-right: 1px solid rgb(200,200,200);
}
div.span-of-time--4 {
width: 37px;
}
div#app {
height: 100%
}
div#toolbar {
border-bottom: 1px solid #282828;
box-shadow: 0px 1px 1px rgb(85,85,85);
}
div#toolbar__left {
display: inline-block;
}
div#toolbar__right {
display: inline-block;
float: right;
}
.ui-text {
color: #BBBBBB;
font-size: 13px;
text-decoration: none;
font-family: 'Martel Sans', sans-serif;
cursor: default;
/* noselect */
-webkit-touch-callout: none; /* iOS Safari */
-webkit-user-select: none; /* Safari */
-khtml-user-select: none; /* Konqueror HTML */
-moz-user-select: none; /* Firefox */
-ms-user-select: none; /* Internet Explorer/Edge */
user-select: none; /* Non-prefixed version, currently
supported by Chrome and Opera */
}
div#toolbar-dropdowns {
position: absolute;
z-index: 2;
}
.toolbar__option {
display: inline-block;
height: 25px;
padding: 2px 5px 0px 5px;
}
.toolbar__option:hover {
color: rgb(225,225,225);
cursor: pointer;
}
div.toolbar__option_active {
background-color: rgb(75,110,175);
}
div#toolbar-dropdowns__song {
margin-left: 86px;
width: 190px;
border: 1px solid dimgray;
}
div.toolbar-dropdown-not-last-option {
border-bottom: 1px solid dimgray;
}
div.toolbar-dropdown-option {
cursor: default;
width: 181px;
display: inline-block;
font-size: 12px;
}
div.toolbar-dropdown-option:hover {
background-color: rgb(75,110,175);
}
.noselect {
-webkit-touch-callout: none; /* iOS Safari */
-webkit-user-select: none; /* Safari */
-khtml-user-select: none; /* Konqueror HTML */
-moz-user-select: none; /* Firefox */
-ms-user-select: none; /* Internet Explorer/Edge */
user-select: none; /* Non-prefixed version, currently
supported by Chrome and Opera */
}
</style>
npm run build
发现了错误。再次工作。问题是我创建了一个名称中带有破折号的条件类,但没有用单引号将类名括起来。所以而不是
:class="{ 'modals-active': modalActive }"
我有
:class="{ modals-active: modalActive }"
.
.vue
的第 29 行。模板文件,但错误消息似乎表明错误在第 72 行。
最佳答案
我有一个类似的问题,原来是这个小代码片段:
item = {
...item,
...this.files[file]
};
关于Vue.js - 模块构建失败 : SyntaxError: Unexpected token,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44880996/
一旦在 qconsole Marklogic 中运行以下代码,我就会遇到以下错误 XDMP-UNEXPECTED: (err:XPST0003) Unexpected token syntax err
我已经在我的包中编写了这个函数。 def partitionIntoDays(ls, number, lookupKey=None): ''' Partitions the location
我只是一个 android 初学者,我已经安装了 Android Studio(版本是 1.0.2),并创建了一个新的空白应用程序,按照名为“构建你的第一个应用程序”的官方教程,我学习到这个页面' h
这只是前几天工作,但我刚刚将我的代码更新到运行乘客 2.2.4 的审查服务器,而我的 2.3.4 rails 应用程序现在无法在那个盒子上启动。 乘客报告: Passenger encountered
我正在尝试使用带有 Angular 2的整页, 将其导入我的 app.module.ts 时出现以下错误。 "(SystemJS) Unexpected token ) at Obje
TFS2015 vNext 构建失败并出现记录器错误(下面附有错误消息)。根据我的调查,这看起来与 CentralLogger - "Microsoft.TeamFoundation.Distribu
计算机科学学校项目。我需要编写一个程序,其中用户声明数组的大小,然后以数字、非递减顺序填充数组,然后声明一个值 x。然后将 X 分配到适当的位置,以便整个数组按数字、非递减顺序排列。然后输出该数组。
在这 2 个方法中,inspect1 显示编译错误“Unexpected bound”而 inspect2 工作正常,为什么? public void inspect1(List u){ S
已关闭。这个问题是 not reproducible or was caused by typos 。目前不接受答案。 这个问题是由拼写错误或无法再重现的问题引起的。虽然类似的问题可能是 on-top
我正在尝试运行以下代码,但遇到了“此时意外”错误。 (echo COPY (SELECT ta.colA as name, ta.colB as user_e, ta.colC as user_n,
我有以下查询: select u.UserName, count(*) as total from Voting v join User u using (UserID) where unique (
我们有以下查询在 MSSQL 中完美运行但在 MySQL 中无法运行: select CONVERT(datetime, dateVal) as DateOccurred, itemID, COUNT
我的代码中存在缩进错误问题。它看起来是正确的...有人能指出我做错了什么吗?我的查询行不断收到错误。 def invoice_details(myDeliveryID): conn = pym
我有以下代码: int a , b , sum; cin>>a>>b; sum=a+b; cout>a>>b>>c; cout<
这个问题不太可能帮助任何 future 的访问者;它只与一个小的地理区域、一个特定的时间点或一个非常狭窄的情况有关,这些情况并不普遍适用于互联网的全局受众。为了帮助使这个问题更广泛地适用,visit
我在一个批处理文件上运行这个命令: for %I in (*.txt *.doc) do copy %I c:\test2 ...它不断返回: I was unexpected at this tim
创建查询时出现错误: 'from' unexpected 我的代码如下: @Override public Admin findByAdmin(Admin admin) {
我正在尝试运行此 python 代码,但我不断收到错误消息“意外缩进”。我不确定怎么了。间距似乎很好。有什么想法吗? services = ['Service1'] for service in
我在名为“circular_dependency”的目录中有一些 python 文件: 导入文件_1.py: from circular_dependency.import_file_2 import
我正在尝试使用 gcc 编译代码并运行可执行文件,但它抛出错误: gcc somefile.c -o somefile 编译成功。但是,当我尝试执行它时: $sh somefile 它导致:语法错误:
我是一名优秀的程序员,十分优秀!