首页 > 解决方案 > 从 react-s3 导入 S3FileUpload 导致 Unexpected Identifier 错误

问题描述

我是 Javascript 编程的新手,并且一直在学习 React。情况是我正在尝试将图像上传到 AWS S3 存储桶。正如标题所说,当我尝试从“react-s3”导入 S3FileUpload 时 SyntaxError:出现意外标识符

我试过用谷歌搜索这个问题,但我发现的唯一错误结果是另一种没有答案的语言:http: //qaru.site/questions/17278232/syntaxerror-unexpected-token-import-while-transpiling-reactjs-应用程序使用 babel

import S3FileUpload from 'react-s3';

这是出现的终端日志:

(function (exports, require, module, __filename, __dirname) { import Signature from "./Signature";
                                                                     ^^^^^^^^^

SyntaxError: Unexpected identifier
    at new Script (vm.js:83:7)
    at createScript (vm.js:267:10)
    at Object.runInThisContext (vm.js:319:10)
    at Module._compile (internal/modules/cjs/loader.js:684:28)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
    at Module.load (internal/modules/cjs/loader.js:620:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
    at Function.Module._load (internal/modules/cjs/loader.js:552:3)
    at Module.require (internal/modules/cjs/loader.js:657:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at Object.<anonymous> (C:\Users\Me\Documents\GitHub\myrepo\node_modules\react-s3\index.js:1:80)
    at Module._compile (internal/modules/cjs/loader.js:721:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
    at Module.load (internal/modules/cjs/loader.js:620:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
    at Function.Module._load (internal/modules/cjs/loader.js:552:3)

任何提示将非常感谢!

标签: reactjsamazon-s3

解决方案


我的错误,我刚刚去了该模块的 Github 存储库,看来该模块的名称已在 6 天前更改为 aws-S3。现在工作!


推荐阅读