开发者问题收集

rxjs-redux observable 安装后无法编译,节点模块问题

2018-05-10
1628

经过两天的裸机安装和尝试按照 Egghead 的指南实现最简单的示例的斗争。

由于某种原因,我在使用节点模块时遇到了麻烦,无法找到它的任何组件。

Epics Index:

import { Observable } from 'rxjs';
import {combineEpics} from 'redux-observable';

function loadStoriesEpic(action$) {
    return action$
        .do(action => console.log(action))
        .ignoreElements();
}

export const rootEpic = combineEpics(loadStoriesEpic);

我在控制台上的实际错误是无法编译的。

RROR in ./node_modules/rxjs/Observable.js Module not found: Error: Can't resolve 'rxjs-compat/Observable' in '/Users/laxosceles/react-portfolio-solstice/node_modules/rxjs' @ ./node_modules/rxjs/Observable.js 6:9-42 @ ./node_modules/redux-observable/lib/esm/ActionsObservable.js @ ./node_modules/redux-observable/lib/esm/index.js @ ./src/index.js @ multi (webpack)-dev-server/client? http://localhost:8080 webpack/hot/dev-server ./src

ERROR in ./node_modules/rxjs/Subject.js Module not found: Error: Can't resolve 'rxjs-compat/Subject' in '/Users/laxosceles/react-portfolio-solstice/node_modules/rxjs' @ ./node_modules/rxjs/Subject.js 6:9-39 @ ./node_modules/redux-observable/lib/esm/createEpicMiddleware.js @ ./node_modules/redux-observable/lib/esm/index.js @ ./src/index.js @ multi (webpack)-dev-server/client? http://localhost:8080 webpack/hot/dev-server ./src

ERROR in ./node_modules/rxjs/observable/from.js Module not found: Error: Can't resolve 'rxjs-compat/observable/from' in '/Users/laxosceles/react-portfolio-solstice/node_modules/rxjs/observable' @ ./node_modules/rxjs/observable/from.js 6:9-47 @ ./node_modules/redux-observable/lib/esm/ActionsObservable.js @ ./node_modules/redux-observable/lib/esm/index.js @ ./src/index.js @ multi (webpack)-dev-server/client? http://localhost:8080 webpack/hot/dev-server ./src

ERROR in ./node_modules/rxjs/observable/merge.js Module not found: Error: Can't resolve 'rxjs-compat/observable/merge' in '/Users/laxosceles/react-portfolio-solstice/node_modules/rxjs/observable' @ ./node_modules/rxjs/observable/merge.js 6:9-48 @ ./node_modules/redux-observable/lib/esm/combineEpics.js @ ./node_modules/redux-observable/lib/esm/index.js @ ./src/index.js @ multi (webpack)-dev-server/client? http://localhost:8080 webpack/hot/dev-server ./src

ERROR in ./node_modules/rxjs/observable/of.js Module not found: Error: Can't resolve 'rxjs-compat/observable/of' in '/Users/laxosceles/react-portfolio-solstice/node_modules/rxjs/observable' @ ./node_modules/rxjs/observable/of.js 6:9-45 @ ./node_modules/redux-observable/lib/esm/ActionsObservable.js @ ./node_modules/redux-observable/lib/esm/index.js @ ./src/index.js @ multi (webpack)-dev-server/client? http://localhost:8080 webpack/hot/dev-server ./src

ERROR in ./node_modules/rxjs/operator/filter.js Module not found: Error: Can't resolve 'rxjs-compat/operator/filter' in '/Users/laxosceles/react-portfolio-solstice/node_modules/rxjs/operator' @ ./node_modules/rxjs/operator/filter.js 6:9-47 @ ./node_modules/redux-observable/lib/esm/operators.js @ ./node_modules/redux-observable/lib/esm/index.js @ ./src/index.js @ multi (webpack)-dev-server/client? http://localhost:8080 webpack/hot/dev-server ./src

ERROR in ./node_modules/rxjs/operator/map.js Module not found: Error: Can't resolve 'rxjs-compat/operator/map' in '/Users/laxosceles/react-portfolio-solstice/node_modules/rxjs/operator' @ ./node_modules/rxjs/operator/map.js 6:9-44 @ ./node_modules/redux-observable/lib/esm/createEpicMiddleware.js @ ./node_modules/redux-observable/lib/esm/index.js @ ./src/index.js @ multi (webpack)-dev-server/client? http://localhost:8080 webpack/hot/dev-server ./src

ERROR in ./node_modules/rxjs/operator/switchMap.js Module not found: Error: Can't resolve 'rxjs-compat/operator/switchMap' in '/Users/laxosceles/react-portfolio-solstice/node_modules/rxjs/operator' @ ./node_modules/rxjs/operator/switchMap.js 6:9-50 @ ./node_modules/redux-observable/lib/esm/createEpicMiddleware.js @ ./node_modules/redux-observable/lib/esm/index.js @ ./src/index.js @ multi (webpack)-dev-server/client? http://localhost:8080 webpack/hot/dev-server ./src Child html-webpack-plugin for "index.html": Asset Size Chunks Chunk Names db7499f085244c16cc8c.hot-update.json 44 bytes [emitted]
+ 1 hidden asset Entrypoint undefined = ./index.html

我不认为这与问题有关,但我还是要说,我最近将 Yarn 添加到我的项目中,现在我使用“yarn add”安装了它,我不认为这应该是一个问题,因为依赖关系显示在了我的 package.json 中

1个回答

我敢打赌你正在使用 rxjs v6redux-observable v.0.x ,因为我看到有导入错误(这就是 rxjs v6 中的重大变化,并且 redux-observable v.0.x 与 rxjs5 兼容)。

你需要 升级 redux-observable 或将 rxjs 降级到版本 5。

github 问题

Tomasz Mularczyk
2018-05-10