2016-11-23 71 views
6

我已經使用create-react-app爲我的項目。我得到的未捕獲SyntaxError:意外的令牌導出

Uncaught SyntaxError: Unexpected token export

的錯誤是一個錯誤在此代碼

export const ENGLISH = { 
    lang: 'en', 
    messages: { 
     'nav.translatedMessage': 'Social', 
    } 
}; 

我嘗試安裝通天預設-ES2015和巴貝爾預設-0級。我還包括在package.json babel字典/對象爲

"babel": { 
    "presets": [ 
     "es2015", 
     "stage-0" 
    ] 
    }, 

我仍然收到錯誤。

enter image description here

+0

在'nav.translatedMessage':'Social''後刪除''',' – Monasha

+0

@Monasha已經嘗試過。它不起作用。這個確切的代碼工作時,我沒有使用create-react-app。 – Serenity

+0

你能發佈完整的錯誤信息嗎? – loganfsmyth

回答

6

我上建立反應的應用程序內的README.md我的答案。在那裏,它說

You may create subdirectories inside src . For faster rebuilds, only files inside src are processed by Webpack.
You need to put any JS and CSS files inside src, or Webpack won’t see them.

-5

我認爲它的逗號

export const ENGLISH = { 
     lang: 'en', 
     messages: { 
      'nav.translatedMessage': 'Social' 
     } 
}; 

嘗試這樣做的原因!

+0

任何現代瀏覽器上的數組項和對象屬性的尾隨逗號都可以。 – loganfsmyth

相關問題