Harmony 集合未在 NodeJS 5 中定义
Harmony Collections Aren't Defined In NodeJS 5
我有一个NodeJS
(v5.0.0),Express
和React
应用程序。
我插入了一些同构,因此我的一些React
应用程序组件加载到 NodeJS
中。
服务器崩溃并显示错误:在我的Alt
商店之一中ReferenceError: Set is not defined
:
import alt from '../alt';
import NewProjectActions from '../actions/NewProjectActions';
import LoginStore from './LoginStore';
import { Base64 } from 'js-base64';
import limits from '../../limits';
class NewProjectStore {
constructor() {
this.bindActions(NewProjectActions);
//State
this.activeStage = 1;
this.projectID = null;
this.projectName = '';
this.hasActiveComponentFinished = false;
this.isLoading = false;
this.assessment = [];
this.selectedClasses = [];
this.assignmentsUploaded = new Set(); <------ THIS LINE FAILS
The page goes on........
我尝试用Map
替换它,它也崩溃了。奇怪的是,你可以看到我使用的是 ES6 import
的,而且运行良好。
我还检查了NodeJS
Docs,它显示Harmony集合附带NodeJS
,不需要任何运行时标志。
我刚刚更新了我的Babel
所以也许这与它有关。
更新:只是为了详细说明,我开始使用Require Hooks
。
有人有想法吗?不用说,我已经通过谷歌,什么也没找到。
感谢您的任何帮助!
更新:我尝试在server.js
页面中使用Set
并且它起作用了。似乎问题确实Babel
浏览这些页面,而不是NodeJS
.我仍然不知道为什么它不同意 ES6 集合。
下面是完整的错误堆栈跟踪:
ReferenceError: Set is not defined
at Store.NewProjectStore (NewProjectStore.js:18:36)
at new Store (/home/ec2-user/projects/peer_reviews/node_modules/alt/lib/store/index.js:155:73)
at Object.createStoreFromClass (/home/ec2-user/projects/peer_reviews/node_modules/alt/lib/store/index.js:175:15)
at Alt.createStore (/home/ec2-user/projects/peer_reviews/node_modules/alt/lib/index.js:129:77)
at Object.<anonymous> (NewProjectStore.js:99:20)
at Module._compile (module.js:456:26)
at loader (/home/ec2-user/projects/peer_reviews/node_modules/babel-register/lib/node.js:130:5)
at Object.require.extensions.(anonymous function) [as .js] (/home/ec2-user/projects/peer_reviews/node_modules/babel-register/lib/node.js:140:7)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/home/ec2-user/projects/peer_reviews/app/routes.js:17:24)
at Module._compile (module.js:456:26)
at loader (/home/ec2-user/projects/peer_reviews/node_modules/babel-register/lib/node.js:130:5)
at Object.require.extensions.(anonymous function) [as .js] (/home/ec2-user/projects/peer_reviews/node_modules/babel-register/lib/node.js:140:7)
我相信
错误与Babel
的Require Hooks
有关。文档说它更适合简单使用,而且由于Babel 6
太新了,我想这只是一个错误。
我通过从命令行切换到激活Babel
来修复它。
可以在此处找到以各种方式激活Babel
的说明。
祝大家好运。
相关文章:
- 在gump和nodejs中使用Typescript时,未定义对require和exports的引用
- Nodejs模块函数返回未定义的,而不是异步的
- 无法读取未定义的属性 - NodeJS,Express,Mongoose
- 如何获取以编程方式定义nodejs函数的位置
- Nodejs会话未定义
- NodeJS'到UpperCase'的未定义(从typescript生成)
- 类型错误:无法读取 Nodejs 中未定义的属性“post”
- Yeoman 应用程序 - 使用自定义 Nodejs 服务器
- 使用 NodeJS 的请求模块进行 HTTP 身份验证,返回未定义的正文
- 处理 nodejs 错误并提供不同自定义消息详细信息的最佳方法
- NodeJS 错误堆栈未定义
- 在 NodeJS 中未定义为 falsey
- nodejs socket 发出返回未定义
- 用.NodeJS 中的 ENV 值,Procfile 定义中的必需键错误
- Nodejs - Req.body 未定义在 post 中,带有快速 4.9.0
- Javascript 函数在 nodejs 中返回未定义的值
- NodeJS 错误与 connect-busboy,“类型错误:无法调用未定义的方法'on'”
- 对象未定义到模块中,Nodejs javascript
- 是否可以将自定义命令添加到 NodeJS 的 Redis 客户端
- 要求的事情.参数在服务器端未定义:nodejs