Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 意外令牌导入网页包babel es2015_Javascript_Webpack_Ecmascript 6_Babeljs - Fatal编程技术网

Javascript 意外令牌导入网页包babel es2015

Javascript 意外令牌导入网页包babel es2015,javascript,webpack,ecmascript-6,babeljs,Javascript,Webpack,Ecmascript 6,Babeljs,我访问了上百个网页,但找不到适合我的解决方案。我正在使用webpack babel,但在尝试导入express时出现错误“意外令牌导入”: .LRC: { "moduleId": "myModule", "presets": ["es2015", "stage-0"], "plugins": ["add-module-exports"] } webpack.config.js: const path = require('path'); const webpa

我访问了上百个网页,但找不到适合我的解决方案。我正在使用webpack babel,但在尝试导入express时出现错误“意外令牌导入”:

.LRC:

 {
    "moduleId": "myModule",
    "presets": ["es2015", "stage-0"],
    "plugins": ["add-module-exports"]
    }
webpack.config.js:

const path = require('path');
const webpack = require("webpack");
const ExtractTextPlugin=require("extract-text-webpack-plugin");

module.exports = {
    context:__dirname + '/front',
    entry:__dirname + '/front/index.js',
    output:{
        path:__dirname + '/public/assets',
        filename:'bundle.js',
        publicPath:'assets'
    },
    resolveLoader: {
        root: path.join(__dirname, 'node_modules')
    },
    plugins:[
        new webpack.DefinePlugin({
            TEST_ENV:process.env.NODE_ENV === "test"
        }),
        new ExtractTextPlugin("bundle.css",
            {
            publicPath: 'assets/core/css',
            allChunks: true
        })
    ],
    module: {
        loaders: [
            {
                test: /\.js/,
                loader: "babel-loader",
                exclude: /(node_modules|bower_components)/,
                query: {
                    presets: ['es2015']}
            },
            {
                test: /\.html/,
                loader: "raw-loader"},
              {
                test: /\.css$/,
                loader: ExtractTextPlugin.extract("style-loader", "css-loader!autoprefixer-loader?browsers=last 3 version")
            },
            {
                test: /\.scss$/,
                loader: ExtractTextPlugin.extract("style-loader", "css-loader!autoprefixer-loader?browsers=last 3 version!sass-loader")
            }
        ]
    },
    devServer: {
        port: 7000,
    },
    devtool: 'source-map',
}
package.json:

{
  "name": "SA-19KV",
  "version": "1.0.0",
  "description": "Project Boilerplate",
  "scripts": {
    "ngdev": "webpack-dev-server --content-base public/ --progress --colors ",
    "nghot": "webpack-dev-server --content-base public/ --progress --colors --inline --hot",
    "test": "set NODE_ENV=test && karma start",
    "prod": "webpack -p",
    "backdev": "nodemon server.js --watch back/"
  },
  "dependencies": {
    "angular": "1.5.0",
    "css-loader": "^0.26.1",
    "express": "^4.14.1",
    "style-loader": "^0.13.1"
  },
  "devDependencies": {
    "angular-mocks": "^1.6.1",
    "autoprefixer-loader": "^3.2.0",
    "babel-core": "^6.22.1",
    "babel-loader": "^6.2.10",
    "babel-plugin-add-module-exports": "^0.2.1",
    "babel-preset-es2015": "^6.22.0",
    "babel-preset-stage-0": "^6.5.0",
    "chai": "^3.5.0",
    "css-loader": "^0.26.1",
    "extract-text-webpack-plugin": "^1.0.1",
    "html-webpack-plugin": "1.6.1",
    "karma": "^1.4.1",
    "karma-chai": "^0.1.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-coverage": "^1.1.1",
    "karma-html-detailed-reporter": "^1.1.15",
    "karma-mocha": "^1.3.0",
    "karma-webpack": "^2.0.2",
    "mocha": "^3.2.0",
    "node-sass": "^4.4.0",
    "nodemon": "^1.11.0",
    "raw-loader": "^0.5.1",
    "sass-loader": "^4.1.1",
    "style-loader": "^0.13.1",
    "webpack": "^1.14.0",
    "webpack-dev-server": "1.14.1"
  },
  "author": "Me :-)",
  "license": "ISC"
}

您的
package.json
脚本未加载您的网页包的配置。您可以通过添加
--config
参数来加载它:

webpack-dev-server --config ./webpack.config.js