我有
import fs from 'fs'
在我的package.json我有
然后我运行命令
> npm i fs > fs@0.0.2 node_modules/fs
接下来在我的React商店中导入’fs’模块
import fs from 'fs'
但是当我尝试使用fs时
我没有看到除了构造函数和一些其他__methods之外的方法.我没有看到方法createReadStream或任何其他文件操作方法.
有人知道出了什么问题吗? (使用Webpack)并可根据要求提供更多信息,但我到目前为止……
ps:为什么我可以npm i fs – 当我在其他帖子上阅读时,我不必这样做(使用节点5.5.0)
import Reflux from 'reflux' import AddItemActions from '../actions/AddItemActions' import request from 'superagent-bluebird-promise' import fs from 'fs' var ImageStore = Reflux.createStore({ init(){ . . . },decryptImage(file) { var reader = new FileReader(); var info = {} reader.onload = (output) => { debugger request.post("https://camfind.p.mashape.com/image_requests") .set("X-Mashape-Key","KEY") .set("Content-Type","application/x-www-form-urlencoded") .set("Accept","application/json") .send({'focus': { 'x': 480}}) .send({'focus': { 'y': 640}}) .send({'image_request': {'altitude': 27.912109375}}) .send({'image_request': {'language': "en"}}) .send({'image_request': {'latitude': 35.8714220766008}}) .send({'image_request': {'locale' : "en_US"}}) .send({'image_request': {'longitude': 14.3583203002251}}) .send({'image_request': {'image': fs.createReadStream("/path" + 'file.jpg')}}) .then(function (result) { console.log(result.status,result.headers,result.body); this.info = result },function(error) { console.log(error); }) } reader.readAsDataURL(file); return info },. . . . })
在create-react-app中,他们已经删除了’fs’.你无法导入它.你必须找到解决这个问题的另一种方法.看到这张票.
https://github.com/facebook/create-react-app/issues/3074
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。