我已经安装了一些做npm install --save ng2-redux redux redux-actions redux-promise的模块。如果我执行npm list | grep "redux",我会得到:
├── ng2-redux@3.0.5
├─┬ redux@3.5.2
├─┬ redux-actions@0.12.0
├─┬ redux-promise@0.5.3在我的package.json中,我也可以找到它们:
"dependencies": {
...
"ng2-redux": "3.0.5",
"redux": "3.5.2",
"redux-actions": "0.12.0",
"redux-promise": "0.5.3",
...
}问题是,虽然ng2-redux和redux都工作得很好:
import { applyMiddleware } from 'redux';
import { NgRedux, select } from 'ng2-redux';redux-actions和redux-promise在尝试导入时都会抛出Cannot resolve file 'redux-actions'/'redux-promise',在集成开发环境(WebStorm 11.0.4)和Webpack中都会出现:
import { createAction } from 'redux-actions';
import promiseMiddleware from 'redux-promise';错误信息显示:
ERROR in ../src/.../app.component.ts
(8,31): error TS2307: Cannot find module 'redux-promise'.然而..。
import 'redux-actions';
import 'redux-promise';...works很好。
我已经尝试删除node_modules文件夹并重新安装npm cache clear、rm -rf node_modules和npm install的所有内容,但都没有解决这个问题。
发布于 2016-12-08 19:20:51
您还应该在node_modules目录下有d.ts文件。试一试
npm install --save-dev @types/redux-promise获取模块的类型信息。
https://stackoverflow.com/questions/39371446
复制相似问题