我已經使用Create-React-App初始化了一個項目。Create-React-App:Uncaught錯誤:無法找到模塊「./locale」
所有工作都OK,如果我...
npm run start
和觀點上http://localhost:3000
或
npm run build && serve -s build
和視圖上http://localhost:5000
但是當我部署到與S3桶...
npm run build && aws s3 sync build/ s3://${DEPLOYMENT_BUCKET}
...我去S3網址,並得到一個空白屏幕與此錯誤控制檯:
Uncaught Error: Cannot find module "./locale"
我想這可能是是與moment.js - 雖然它不是依賴我已經添加。
展望我node_modules我能看到的moment.js是2.18.1版本,我認爲規則出this answer
我不知道如何調試這個問題,所以任何幫助表示讚賞。
不知道這是否有幫助,但我目前的package.json如下。
{
"name": "my_app",
"version": "1.0.0",
"private": true,
"dependencies": {
"amazon-cognito-identity-js": "^1.19.0",
"antd": "^2.13.4",
"axios": "^0.16.2",
"react": "^15.6.1",
"react-dom": "^15.6.1",
"react-router-dom": "^4.2.2",
"react-scripts": "1.0.13",
"recompose": "^0.25.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
您是否嘗試過將momentJS添加爲顯式依賴項,以查看它是否修復了您的問題?至於爲什麼它被使用和丟失,它可能與你的建設過程有關,這在你的問題中沒有詳細說明。它可以用作你正在使用的軟件包中的一個軟件包的依賴項,然後在構建過程中被忽略。 – Jaxx
多煩人 - 是增加時刻作爲依賴已修復它 - 乾杯@jaxx – Luke
我給的答案根本沒有幫助?爲了您的緣故,我希望您在生成構建配置中註釋掉一行後,不必添加此依賴項。 – Jaxx