Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
VS代码上带有Node.js和RXJS的简单测试项目_Node.js - Fatal编程技术网

VS代码上带有Node.js和RXJS的简单测试项目

VS代码上带有Node.js和RXJS的简单测试项目,node.js,Node.js,我觉得做不到这一点很傻,但我正在尝试创建一个简单的项目,在VS代码中使用Node.js上的一些RXJS mkdir test cd test code . type nul > app.js npm init npm install rxjs app.js包含 import * as rxjs from 'rxjs'; rxjs.of(1, 2, 3); var msg = 'Hello World'; console.log(msg); 调试应用程序时出现运行时错误:(节点:99

我觉得做不到这一点很傻,但我正在尝试创建一个简单的项目,在VS代码中使用Node.js上的一些RXJS

mkdir test
cd test
code .
type nul > app.js
npm init
npm install rxjs
app.js包含

import * as rxjs from 'rxjs';

rxjs.of(1, 2, 3);

var msg = 'Hello World';
console.log(msg);
调试应用程序时出现运行时错误:
(节点:9988)警告:要加载ES模块,请在package.json中设置“type”:“module”或使用.mjs扩展名。

所以我补充说:

"type": "module"
到package.json:

{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "type": "module",
  "main": "app.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "rxjs": "^6.5.4"
  }
}
现在我得到了
TypeError:rxjs.of不是一个函数

为什么做这么简单的事情这么复杂? 这是怎么回事?

而不是

import * as rxjs from 'rxjs';
使用

当前节点不支持esmodules

const rxjs = require('rxjs');