这是我在package.json中的脚本
"scripts": {
"start": "npm-run-all --parallel development",
"development": "babel-node node_modules/.bin/webpack-dev-server --inline --progress --colors --config ./buildScripts/webpack.dev.js"
}
这是我的webpack.dev.js
import path from 'path';
import webpack from 'webpack';
import chalk from 'chalk';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import ExtractTextPlugin from 'extract-text-webpack-plugin';
let argv = require('yargs').argv;
let DEV_SERVER_PORT = 3001;
if (typeof argv.portNumber === 'number') {
DEV_SERVER_PORT = argv.portNumber;
}
console.log(chalk.blue(`Starting server of ${DEV_SERVER_PORT}.`));
const nodeModulesDir = path.resolve(__dirname, 'node_modules');
export default {
debug: true,
devtool: 'eval',
devServer: {
contentBase: './src',
compress: true,
port: DEV_SERVER_PORT,
stats: 'minimal',
historyApiFallback: {
index: '/'
}
},
noInfo: false,
entry: {
vendor: path.resolve(__dirname, './../src/app/vendor'),
webstandards: path.resolve(__dirname, './../src/web-standards/'),
main: [path.resolve(__dirname, './../src/app/main')]
},
target: 'web',
output: {
pathinfo: true,
path: path.resolve(__dirname, './../src'),
publicPath: '/',
filename: '[name].js'
},
plugins: [
// Create HTML file that includes reference to bundled JS.
new HtmlWebpackPlugin({
template: '!!pug!src/index.pug',
favicon: 'src/favicon.ico',
inject: true,
devServer: 'http://localhost:' + DEV_SERVER_PORT,
baseHref: '/',
}),
new ExtractTextPlugin("[name].css", {
allChunks: false
}),
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
],
module: {
loaders: [{
test: /\.js?$/,
exclude: [nodeModulesDir],
loader: 'ng-annotate!babel?compact=false'
}, {
test: /\.css$/,
exclude: [nodeModulesDir],
loader: ExtractTextPlugin.extract("style-loader", "css"),
}, {
test: /\.scss$/,
loader: ExtractTextPlugin.extract("style-loader", "css!sass"),
exclude: [nodeModulesDir]
}, {
test: /\.html$/,
loader: 'html',
exclude: [nodeModulesDir]
}, {
// Load images
test: /\.(png|jpg|jpeg|gif)$/,
loader: 'url?limit=5000&name=images/[name].[ext]'
}, {
test: /\.((woff2?|svg)(\?v=[0-9]\.[0-9]\.[0-9]))|(woff2? |svg)$/,
loader: "url?limit=10000"
}, {
test: /\.((ttf|eot)(\?v=[0-9]\.[0-9]\.[0-9]))|(ttf|eot)$/,
loader: "file"
}]
}
}
当我使用npm start
运行项目时我收到错误 这是我的控制台窗口44的摘录
E:\ mobile-standards> npm start
webstandards@1.0.7启动E:\ mobile-standards npm-run-all - 并行开发
webstandards@1.0.7开发E:\ mobile-standards babel-node node_modules / .bin / webpack-dev-server --inline --progress - colors --config ./buildScripts/webpack.dev.js
E:\移动标准\ node_modules.bin \的WebPack-DEV-服务器:2 basedir = $(dirname" $(echo" $ 0" | sed -e' s,\,/,g')") ^^^^^^^
参数列表后面的SyntaxError:missing) 在createScript(vm.js:56:10) 在Object.runInThisContext(vm.js:97:10) 在Module._compile(module.js:542:28) 在Module._extensions..js(module.js:579:10) at Object.require.extensions。(匿名函数)[as .js](E:\ mobile-standa RDS \ node_modules \巴贝尔寄存器\ lib中\的node.js:152:7) 在Module.load(module.js:487:32) 在tryModuleLoad(module.js:446:12) 在Function.Module._load(module.js:438:3) 在Function.Module.runMain(module.js:604:10) 在E:\ mobile-standards \ node_modules \ babel-cli \ lib_babel-node.js:159:24
现在,我已经在Windows系统上指定节点模块路径时完成了对此错误的研究。
但是没有运气。
有人可以朝着正确的方向推动我。