我对rxjs(v6(和commmonJsDependencies有问题。
我尝试导入takeUntil并将JSDependency附加到angular.json allowedCommonJsDependencies数组中。
我一直看到一个错误:
Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import '/Users/d/angular/node_modules/rxjs/operators' is not supported resolving ES modules imported from /Users/d/angular/node_modules/@angular/core/fesm2015/core.mjs
Did you mean to import rxjs/operators/index.js
我尝试过:
import { takeUntil } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import { takeUntil } from 'rxjs/operators/index';
和allowedCommonJsDependencies:
- rxjs
- rxjs/运算符
- rxjs/运算符/索引
.ts文件和config.json文件中应该包含什么?
编辑:我使用es2015
src/tsconfig.json
{
"compilerOptions": {
"baseUrl": "",
"declaration": false,
"experimentalDecorators": true,
"lib": ["es6", "dom"],
"mapRoot": "./",
"module": "es6",
"moduleResolution": "node",
"outDir": "../dist/out-tsc",
"sourceMap": true,
"target": "es2015",
"typeRoots": [
"../node_modules/@types"
]
}
}
"角度/动画":"13.1.0";,"角度/cdk":"13.0.3〃;,"角/公共":"13.1.0";,"angular/compiler":"13.1.0";,"角/芯":"13.1.0";,"角度/形式":"13.1.0";,"角度/平台浏览器":"13.1.0";,"角/平台浏览器动态":"13.1.0";,"角/平台服务器":"13.1.0";,"角度/路由器":"13.1.0";,
"rxjs":"6.6.7";,"typescript":"4.4.4";
即使我去掉了每个rxjs/operators
,我仍然有相同的错误:rxjs/operators' is not supported resolving ES modules imported from ...
(我用rxjs/internal/operators
替换了rxjs/operators
(
在我的案例中,唯一的解决方案是将RXJS升级到7.4。