这是我的设置:
NodeJS:7.6.0
的package.json
{
"name": "Fieldstart",
"version": "1.0.0",
"description": "Fieldstart",
"main": "webpack.config.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"babel": "babel",
"webpack": "webpack"
},
"author": "Conrad Brinker",
"license": "ISC",
"dependencies": {
"axios": "^0.15.3",
"babel": "^6.23.0",
"babel-cli": "^6.24.0",
"babel-core": "6.24.0",
"babel-loader": "^6.4.0",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-react-html-attrs": "^2.0.0",
"babel-plugin-transform-class-properties": "^6.23.0",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-preset-es2015": "^6.24.0",
"babel-preset-react": "^6.23.0",
"babel-preset-stage-0": "^6.22.0",
"gulp": "3.9.1",
"gulp-concat": "2.6.1",
"gulp-rename": "1.2.2",
"gulp-sass": "3.1.0",
"gulp-uglify": "2.0.1",
"node-sass": "4.5.0",
"react": "15.4.2",
"react-dom": "15.4.2",
"react-redux": "^5.0.3",
"react-router": "^4.0.0",
"react-router-redux": "^4.0.8",
"redux": "^3.6.0",
"redux-thunk": "^2.2.0",
"remote-redux-devtools": "^0.5.7",
"webpack": "^2.2.1"
}
}
webpack.config.js
const debug = process.env.NODE_ENV !== "production";
const webpack = require('webpack');
const path = require('path');
module.exports = {
context: path.join(__dirname, "jsx"),
devtool: debug ? "inline-sourcemap" : null,
watch: true,
//devtool: 'source-map',
entry: "./jsx/main.js",
output: {
path: path.resolve(__dirname + "/../html/app"),
filename: "fs.js",
publicPath: "/js/"
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: "babel-loader",
options: {
presets: ['react', 'es2015', 'stage-0'],
plugins: ['react-html-attrs', 'transform-decorators-legacy', 'transform-class-properties']
}
}
]
},
resolve: {
extensions: ['.js']
},
plugins: debug ? [] : [
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({
compress: { screw_ie8: true, warnings: false },
mangle: false,
sourcemap: false,
comments: false
})
]
};
当我去跑步时#n;运行webpack"我得到了这个输出
> Fieldstart@1.0.0 webpack /var/www/src
> webpack
/var/www/src/node_modules/webpack/bin/webpack.js:17
.usage("webpack " + require("../package.json").version + "\n" +
^
TypeError: require(...).usage is not a function
at Object.<anonymous> (/var/www/src/node_modules/webpack/bin/webpack.js:17:3)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:422:7)
at startup (bootstrap_node.js:143:9)
at bootstrap_node.js:537:3
我的配置和网络包有问题吗?我一直试图找到答案,并以不同的方式更改我的配置,但没有运气。
答案 0 :(得分:0)
您的配置不是问题。但似乎webpack的一个依赖项存在问题,即yargs
。 npm可能存在一个问题,它安装了它的破坏版本。您应该删除node_modules
并重新安装依赖项,并确保它不使用缓存中的相同broekn包,您也可以清除npm缓存。
rm -rf node_modules
npm cache clear
npm install