我正在使用webpack将我的代码库放在一起,并且我继续收到错误消息“找不到模块'react-redux'”。
我已经检查了我的node-modules文件夹,确实在那里。我的代码是正确的拼写。我已经删除了整个节点模块文件夹并重新安装它们。
我甚至在全球范围内安装了react-redux(必要时,无论是单独反应还是还原反应)。我不确定我认为这会完成什么,但此时我很绝望。
如果有任何其他信息/代码相关,请发表评论,我会整天观看(11.14.16)
有问题的代码
import * as React from "react";
import { createStore } from 'redux';
import { connect } from 'react-redux';
import * as some from 'lodash/collection/some';
的package.json
{
"name": "xxxxxx",
"private": true,
"scripts": {
"init": "npm install & bower install & typings install & wait; echo Init done.",
"build-css": "gulp styles",
"build-js": "webpack",
"prod:build": "ENV=prod webpack && ENV=prod gulp rev",
"prod:commit": "git rm $(git ls-files --deleted 2.0/assets/scripts/ 2.0/assets/styles/) && git add 2.0/assets/scripts/app*.js 2.0/assets/styles/main*.css rev-manifest.json && git commit -m 'prod assets'"
},
"dependencies": {
"basscss-sass": "^4",
"bootstrap-sass": "^3.3.6",
"classnames": "^2.2.3",
"corejs-typeahead": "^0.11.1",
"font-awesome": "^4.3.0",
"fullcalendar": "^2",
"imagesloaded": "^3",
"jquery": "^1",
"jquery-validation": "^1.14.0",
"lodash": "^3",
"magnific-popup": "^1.1",
"malihu-custom-scrollbar-plugin": "^3.1",
"modularized-normalize-scss": "^4",
"moment": "^2.10.6",
"react": "^0.14.6",
"react-bootstrap": "^0.28.2",
"react-dom": "^0.14.6",
"react-redux": "^4.4.5",
"react-truncate": "^2.0.1",
"redux": "^3.6.0",
"signals": "^1.0.0",
"url-parse": "^1.0.5",
"waypoints": "^4.0.0"
},
"devDependencies": {
"del": "^2.0",
"exports-loader": "^0.6.2",
"gulp": "^3.9",
"gulp-autoprefixer": "^3.0.1",
"gulp-debug": "^2.0.1",
"gulp-if": "^2",
"gulp-livereload": "^3.8.0",
"gulp-minify-css": "^1.2.1",
"gulp-pixrem": "^1",
"gulp-plumber": "^1.0.0",
"gulp-rev-all": "^0.8",
"gulp-sass": "^2",
"gulp-sass-lint": "^1.1.1",
"gulp-sourcemaps": "^1.6",
"imports-loader": "^0.6.4",
"ng-annotate-webpack-plugin": "^0.1.2",
"ts-loader": "^0.8.2",
"typescript": "^1.8.10",
"webpack": "^1.12.1"
}
}
webpack.config.js
var webpack = require("webpack");
var config = {
env: (process.env.ENV || "dev") // `prod` or `dev`
}
plugins = [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: (config.env === "prod" ? '"production"' : '"development"')
}
}),
new webpack.ResolverPlugin(
new webpack.ResolverPlugin.DirectoryDescriptionFilePlugin("bower.json", ["main"])
),
// Until webpack@2 we need this. See https://github.com/webpack/webpack/issues/198
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
new webpack.ProvidePlugin({"window.jQuery": "jquery"})
];
if (config.env === "prod") {
plugins.push(
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
drop_console: true
},
comments: false
})
);
}
module.exports = {
entry: "./2.0/src/scripts/app.ts",
output: {
path: __dirname + "/2.0/src/scripts",
filename: "app.js"
},
module: {
loaders: [
{ test: /\.tsx?$/, loaders: ['ts-loader']},
{ test: /mousewheel\.js/, loader: 'imports?define=>false'} // See https://github.com/malihu/malihu-custom-scrollbar-plugin/issues/371
]
},
resolve: {
fallback: [__dirname+'/bower_components'],
extensions: ["", ".web.js", ".ts", ".tsx", ".js"]
},
plugins: plugins,
devtool: (config.env === "dev" ? "eval" : false)
};
typings.json
{
"name": "xxxxxx",
"dependencies": {},
"globalDependencies": {
"classnames": "registry:dt/classnames#0.0.0+20160316155526",
"fullcalendar": "registry:dt/fullcalendar#1.6.1+20160317120654",
"jquery": "registry:dt/jquery#1.10.0+20160417213236",
"lodash": "registry:dt/lodash#3.10.0+20160720001309",
"mcustomscrollbar": "registry:dt/mcustomscrollbar#2.8.2+20160604165202",
"moment": "registry:dt/moment#2.8.0+20160316155526",
"moment-node": "registry:dt/moment-node#2.11.1+20160511043338",
"react": "registry:dt/react#0.14.0+20160602151522",
"react-bootstrap": "registry:dt/react-bootstrap#0.0.0+20160713061231",
"react-dom": "registry:dt/react-dom#0.14.0+20160412154040",
"react-redux": "registry:dt/react-redux#4.4.0+20160724070751",
"redux": "registry:dt/redux#3.5.2+20160703092728",
"tooltipster": "registry:dt/tooltipster#0.0.0+20160317120654"
}
}