質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
AWS(Amazon Web Services)

Amazon Web Services (AWS)は、仮想空間を機軸とした、クラスター状のコンピュータ・ネットワーク・データベース・ストーレッジ・サポートツールをAWSというインフラから提供する商用サービスです。

React.js

Reactは、アプリケーションのインターフェースを構築するためのオープンソースJavaScriptライブラリです。

Q&A

0回答

720閲覧

aws-amplify import時の 'crypto' エラー

Zett-8

総合スコア8

AWS(Amazon Web Services)

Amazon Web Services (AWS)は、仮想空間を機軸とした、クラスター状のコンピュータ・ネットワーク・データベース・ストーレッジ・サポートツールをAWSというインフラから提供する商用サービスです。

React.js

Reactは、アプリケーションのインターフェースを構築するためのオープンソースJavaScriptライブラリです。

0グッド

0クリップ

投稿2018/08/14 10:04

前提・実現したいこと

Reactでaws cognitoを使い、ユーザー認証を実装しようとしているのですが、
aws-amplifyをimportした時点で以下のエラーが出てしまい、解決できずにいます。

発生している問題・エラーメッセージ

Uncaught TypeError: Cannot read property 'crypto' of undefined

webpack.config.js

javascript

1const path = require('path') 2const webpack = require('webpack') 3const HtmlWebpackPlugin = require('html-webpack-plugin') 4 5module.exports = { 6 resolve: { 7 extensions: ['.js', '.jsx'] 8 }, 9 10 entry: { 11 main: ['babel-polyfill', path.resolve(__dirname, 'src/index.jsx')] 12 }, 13 14 output: { 15 path: path.resolve(__dirname, 'dist'), 16 filename: '[name].js', 17 // publicPath: './' 18 }, 19 20 devServer: { 21 historyApiFallback: true 22 }, 23 24 devtool: process.env.NODE_ENV === 'development' ? 'source-map' : false, 25 26 module: { 27 rules: [ 28 { 29 test: /.(js|jsx)$/, 30 exclude: '/node_modules/', 31 use: [ 32 { 33 loader: 'babel-loader', 34 options: { 35 presets: ['env', 'react'], 36 plugins: ['transform-class-properties'] 37 } 38 } 39 ] 40 }, 41 { 42 test: /.css$/, 43 use: [ 44 'style-loader', 45 { loader: 'css-loader'} 46 ] 47 }, 48 { 49 test: /.(png|jpg|gif)$/, 50 loader: 'file-loader', 51 options: {}, 52 }, 53 { 54 include: path.resolve(__dirname, 'src'), 55 test: /.json$/, 56 use: { 57 loader: 'json-loader', 58 }, 59 }, 60 ] 61 }, 62 63 optimization: { 64 splitChunks: { 65 name: 'vendor', 66 chunks: 'initial', 67 // test: '/node_modules/', 68 // enforce: true 69 } 70 }, 71 72 plugins: [ 73 new webpack.ProgressPlugin(), 74 new HtmlWebpackPlugin({ template: './src/index.html' }), 75 new webpack.DefinePlugin({ 76 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV) 77 }) 78 ] 79} 80

package.json

json

1{ 2 "name": "app", 3 "version": "1.0.0", 4 "description": "", 5 "main": "index.js", 6 "homepage": "/", 7 "scripts": { 8 "dev": "export NODE_ENV=development && webpack-dev-server --mode development --port 8001 --contentBase=dist", 9 "build:prod": "export NODE_ENV=production && webpack --mode production", 10 "build:dev": "export NODE_ENV=development && webpack --mode development" 11 }, 12 "author": "", 13 "license": "ISC", 14 "devDependencies": { 15 "babel-core": "^6.26.3", 16 "babel-loader": "^7.1.5", 17 "babel-plugin-transform-class-properties": "^6.24.1", 18 "babel-polyfill": "^6.26.0", 19 "babel-preset-env": "^1.7.0", 20 "babel-preset-es2015": "^6.24.1", 21 "babel-preset-react": "^6.24.1", 22 "css-loader": "^1.0.0", 23 "file-loader": "^1.1.11", 24 "html-webpack-plugin": "^3.2.0", 25 "json-loader": "^0.5.7", 26 "style-loader": "^0.22.0", 27 "url-loader": "^1.0.1", 28 "webpack": "^4.16.5", 29 "webpack-cli": "^3.1.0", 30 "webpack-dev-server": "^3.1.5" 31 }, 32 "dependencies": { 33 "aws-amplify": "^1.0.5", 34 "aws-amplify-react": "^1.0.5", 35 "aws-sdk": "^2.292.0", 36 "react": "^16.4.2", 37 "react-dom": "^16.4.2", 38 "react-redux": "^5.0.7", 39 "react-router-dom": "^4.3.1", 40 "redux": "^4.0.0", 41 "redux-logger": "^3.0.6", 42 "redux-thunk": "^2.3.0" 43 } 44}

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問