首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >您可能需要一个适当的加载程序才能在windows上加载此文件,而不是在linux和mac os中加载此文件。

您可能需要一个适当的加载程序才能在windows上加载此文件,而不是在linux和mac os中加载此文件。
EN

Stack Overflow用户
提问于 2016-07-30 02:25:56
回答 2查看 1.2K关注 0票数 2

我正在尝试编写一个webpack文件,该文件将使用es6支持在reactjs中创建一个项目。这是我的webpack.config.js

代码语言:javascript
复制
webpackConfig = {
    /*entry: './index.js',
    output: {
        path: path.resolve(__dirname, 'dist/'),
        filename: 'build.js'
    },*/
    entry: { 
        lite: "./lite.js", pro: "./pro.js",
    },
    output: { filename: "dist/[name].js" },
    plugins: [ 
        new webpack.optimize.CommonsChunkPlugin("dist/init.js"),
        new WebpackNotifierPlugin({alwaysNotify: true, title: 'Webpack'})
     ],
    module: {
        loaders: [
            {
                test: /\.(js|jsx)$/,
                exclude: /node_modules/,
                include: __dirname + '/src',
                loader: 'babel-loader',
                query: {
                    presets: ['react','es2015']
                }
            },
            {
                test: /\.css$/,
                loader: ExtractTextPlugin.extract('style-loader', 'css-loader?modules')
            },
            {
                test: /\.html$/,
                loader: 'html-loader'
            },
            {
                test: /\.less$/,
                loader: "style!css!less"
            },
            {
                test: /\.(jpe?g|png|gif|svg)$/i,
                loaders: [
                    'file?hash=sha512&digest=hex&name=[hash].[ext]',
                    'image-webpack?bypassOnDebug&optimizationLevel=7&interlaced=false'
                ]
            }
            // { test: /\.css$/, loader: "style-loader!css-loader" },
        ]
    }
};

这是我的.babelrc文件

代码语言:javascript
复制
{
  "presets" : ["es2015", "react"]
}

它在mac os和linux上运行,但当我试图在windows中运行它时,它遇到了问题。对这个错误有什么解释吗??这很奇怪。

这是错误

代码语言:javascript
复制
ERROR in ./src/lite.js
Module parse failed: C:\xampp\htdocs\ONLINE\CF7\cf7visualPlugin\wp-content\plugins\cf7s                           kins-visual\src\lite.js Unexpected token (9:12)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (9:12)
    at Parser.pp$4.raise (C:\xampp\htdocs\ONLINE\CF7\cf7visualPlugin\wp-content\plugins                           \cf7skins-visual\node_modules\webpack\node_modules\acorn\dist\acorn.js:2221:15)
    at Parser.pp.unexpected (C:\xampp\htdocs\ONLINE\CF7\cf7visualPlugin\wp-content\plug                           ins\cf7skins-visual\node_modules\webpack\node_modules\acorn\dist\acorn.js:603:10)
    at Parser.pp$3.parseExprAtom (C:\xampp\htdocs\ONLINE\CF7\cf7visualPlugin\wp-content                           \plugins\cf7skins-visual\node_modules\webpack\node_modules\acorn\dist\acorn.js:1822:12)
    at Parser.pp$3.parseExprSubscripts (C:\xampp\htdocs\ONLINE\CF7\cf7visualPlugin\wp-c                           ontent\plugins\cf7skins-visual\node_modules\webpack\node_modules\acorn\dist\acorn.js:17                           15:21)
    at Parser.pp$3.parseMaybeUnary (C:\xampp\htdocs\ONLINE\CF7\cf7visualPlugin\wp-conte                           nt\plugins\cf7skins-visual\node_modules\webpack\node_modules\acorn\dist\acorn.js:1692:1                           9)
    at Parser.pp$3.parseExprOps (C:\xampp\htdocs\ONLINE\CF7\cf7visualPlugin\wp-content\                           plugins\cf7skins-visual\node_modules\webpack\node_modules\acorn\dist\acorn.js:1637:21)
    at Parser.pp$3.parseMaybeConditional (C:\xampp\htdocs\ONLINE\CF7\cf7visualPlugin\wp                           -content\plugins\cf7skins-visual\node_modules\webpack\node_modules\acorn\dist\acorn.js:                           1620:21)
    at Parser.pp$3.parseMaybeAssign (C:\xampp\htdocs\ONLINE\CF7\cf7visualPlugin\wp-cont                           ent\plugins\cf7skins-visual\node_modules\webpack\node_modules\acorn\dist\acorn.js:1597:                           21)
    at Parser.pp$3.parseParenAndDistinguishExpression (C:\xampp\htdocs\ONLINE\CF7\cf7vi                           sualPlugin\wp-content\plugins\cf7skins-visual\node_modules\webpack\node_modules\acorn\d                           ist\acorn.js:1861:32)
    at Parser.pp$3.parseExprAtom (C:\xampp\htdocs\ONLINE\CF7\cf7visualPlugin\wp-content                           \plugins\cf7skins-visual\node_modules\webpack\node_modules\acorn\dist\acorn.js:1796:19)
 @ ./lite.js 2:0-24
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-07-30 03:26:39

试着改变这一行:

包括:__dirname + '/src',

对此:

排除:/节点_模块/,

票数 0
EN

Stack Overflow用户

发布于 2016-07-30 05:13:53

它通过改变对我有效

代码语言:javascript
复制
include: __dirname + '/src',

代码语言:javascript
复制
include: path.join(__dirname, 'src')
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38669804

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档