电子中的Mobx未捕获语法错误

时间:2018-08-23 09:44:29

标签: reactjs electron mobx mobx-react

这是我使用mobx运行的代码:

import { observable, decorate } from 'mobx'
class store {
  infoData = ''
};
decorate(store, {
  infoData: observable
})

export default new store

我有一个: "devDependencies": { "babel-preset-es2015": "^6.24.1", "babel-preset-react": "^6.24.1", "electron-prebuilt-compile": "^2.0.7", "electron-react-devtools": "^0.5.3", "electron-rebuild": "^1.8.2" }, "dependencies": { "mobx": "^4.3.2", "mobx-react": "^5.2.5", "react": "^16.4.2", "react-dom": "^16.4.2", }

这些是我在运行应用程序时遇到的错误:

 C:\Users\shaha\Documents\electron-react-starter-kit\node_modules\babel-core\lib\transformation\file\index.js:558 Uncaught SyntaxError: C:/Users/shaha/Documents/electron-react-starter-kit/app/components/mobx.js: Unexpected token (4:9)
    at Parser.pp$5.raise (C:\Users\shaha\Documents\electron-react-starter-kit\node_modules\babylon\lib\index.js:4454)
    at Parser.pp.unexpected (C:\Users\shaha\Documents\electron-react-starter-kit\node_modules\babylon\lib\index.js:1761)
    at Parser.pp$1.parseClassProperty (C:\Users\shaha\Documents\electron-react-starter-kit\node_modules\babylon\lib\index.js:2571)
    at Parser.parseClassProperty (C:\Users\shaha\Documents\electron-react-starter-kit\node_modules\babylon\lib\index.js:6157)
    at Parser.pp$1.parseClassBody (C:\Users\shaha\Documents\electron-react-starter-kit\node_modules\babylon\lib\index.js:2516)
    at Parser.pp$1.parseClass (C:\Users\shaha\Documents\electron-react-starter-kit\node_modules\babylon\lib\index.js:2406)
    at Parser.pp$1.parseStatement (C:\Users\shaha\Documents\electron-react-starter-kit\node_modules\babylon\lib\index.js:1843)
    at Parser.parseStatement (C:\Users\shaha\Documents\electron-react-starter-kit\node_modules\babylon\lib\index.js:5910)
    at Parser.pp$1.parseBlockBody (C:\Users\shaha\Documents\electron-react-starter-kit\node_modules\babylon\lib\index.js:2268)

尽管为反应电子克隆了不同的样板,但我无法通过此错误。

如何避免它们?

1 个答案:

答案 0 :(得分:0)