【问题标题】:Webpack reports error: __diranme is not defined [closed]Webpack 报告错误:__diranme 未定义 [关闭]
【发布时间】:2016-07-08 06:10:07
【问题描述】:

我是 NodeJS 和 webpack 的新手。

我正在关注 webpack 的教程以及何时必须创建 webpack.config.js 并运行 webpack -c webpack.config.js 它返回:

webpack -c webpack.config.js

/home/arma/bin/nodejs/webpack.config.js:15
        root: path.join(__diranme, './src'),
                        ^
ReferenceError: __diranme is not defined
    at Object.<anonymous> (/home/arma/bin/nodejs/webpack.config.js:15:25)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at module.exports (/usr/lib/node_modules/webpack/bin/convert-argv.js:80:13)
    at Object.<anonymous> (/usr/lib/node_modules/webpack/bin/webpack.js:39:40)
    at Module._compile (module.js:456:26)

我的 webpack.config.js:

var path = require('path');

module.exports = {
    context: __dirname,
    entry: [
        './src/index.js',
    ],
    output: {
        path: path.join(__dirname, 'build'),
        filename: 'output.js',
        publicPath: 'assets',
    },
    resolve: {
        extensions: ['','.js'],
        root: path.join(__diranme, './src'),
    }
};

我的系统 Fedora 23:

Linux x-wing 4.4.5-300.fc23.x86_64 #1 SMP Thu Mar 10 17:54:44 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

NodeJS 版本:

v0.10.42

【问题讨论】:

  • 我认为这个问题需要删除 - 有用的标题,但解决方案通常对这个错误没有帮助。

标签: javascript node.js webpack dirname


【解决方案1】:

重命名为 __dirname。您在解决部分中有错字。也在你的帖子标题中:-)

【讨论】:

  • 我真是个白痴!谢谢 :) 但现在我在找不到多主模块中遇到错误:错误:无法解析 __dirname @ multi main 中的“文件”或“目录”./src/index.js
  • 请将错字问题标记为离题。
  • 将问题标记为离题的更好方法是什么?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-09-15
  • 1970-01-01
  • 1970-01-01
  • 2021-02-13
  • 2021-09-14
相关资源
最近更新 更多