我一直在webpack中遇到这个非常烦人的错误,即使我运行webpack --display-error-details
,也没有错误。但是无论何时我运行webpack-dev-server
我都会收到以下错误。我真的看不出我的配置出错了。
Entry module not found: Error: Cannot resolve 'file' or 'directory'
./frontend/app.jsx
module.exports = {
context: __dirname,
entry: './frontend/app.jsx',
output: {
filename: 'bundle.js',
path: __dirname
},
module: {
loaders: [
{
test: [ /\.js$/, /\.jsx$/],
exclude: /(node_modules)/,
loader: 'babel-loader',
query: {
presets: ['es2015', 'react']
}
},
{
test: /\.scss$/,
use: ['style-loader', 'css-loader', 'sass-loader']
}
]
},
devtool: 'source-map',
resolve: {
extensions: ['.js', '.jsx', '.scss' ]
}
};
{
"name": "basicapp",
"version": "1.0.0",
"description": "",
"main": "app.jsx",
"author": "",
"license": "ISC",
"scripts": {
"start": "webpack-dev-server --env development",
"dev-server": "nodemon ./server.js localhost 8080",
"build": "webpack --env production"
},
"dependencies": {
"babel-cli": "^6.24.0",
"babel-core": "^6.24.0",
"babel-loader": "^6.4.1",
"babel-preset-es2015": "^6.24.0",
"babel-preset-react": "^6.23.0",
"css-loader": "^0.27.3",
"express": "^4.15.2",
"express-graphql": "^0.6.3",
"lodash": "^4.17.4",
"node-sass": "^4.5.1",
"react": "^15.4.2",
"react-dom": "^15.4.2",
"react-redux": "^5.0.3",
"react-router": "^4.0.0",
"redux": "^3.6.0",
"sass-loader": "^6.0.3",
"webpack": "^2.3.2"
},
"devDependencies": {
"html-webpack-plugin": "^2.28.0",
"node-sass": "^4.5.1",
"nodemon": "^1.11.0",
"sass-loader": "^6.0.3"
}
}
答案 0 :(得分:0)
Webpack可能没有按照您的意愿处理__dirname,可能正在将其解析为/。尝试将此添加到您的webpack配置:
{
node: {
__dirname: true
}
}
答案 1 :(得分:0)
这可能是由于多种原因,确定确切问题的最佳方法是尝试以下两个命令:
如果您单独运行webpack 1/2,请使用代码段:
#include "RandomDotNet.h"
#include "RandomPS5.h"
#include <Windows.h>
// Length of charset string
#define CHARSETLEN 62
// Random charset
const char charset[CHARSETLEN + 1] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
// Function that processes a record like PowerShell does for -ObjectList
void processRecord(CHAR *string, int len, Random *r) {
// Processed characters
int processed = 0;
int i, indexToReplace;
CHAR temp;
// Iterate the charset
for (i = 0; i < CHARSETLEN; ++i) {
if (processed < len) {
string[processed] = charset[i];
}
else if (r->Next(processed + 1) < len) {
string[r->Next(len)] = charset[i];
}
++processed;
}
// Iterate selected items to return them in "random" order
for (i = 0; i < len; ++i) {
// Get random index
indexToReplace = r->Next(i, len);
if (i != indexToReplace) {
// Swap
temp = string[i];
string[i] = string[indexToReplace];
string[indexToReplace] = temp;
}
}
// Terminate the string
string[len] = '\0';
}
int main(int argc, char* argv[]){
// Example usage with a given seed
Random *r = new RandomPS5(1000);
// Length of random string
int len = 49;
// Random string buffer
CHAR *buffer = (CHAR*)malloc(len + 1);
// ([char[]](Get-Random -Input $(48..57 + 65..90 + 97..122) -Count 49 -SetSeed 1000)) -Join ""
processRecord(buffer, len, r);
// Produces: y6FLfcKrpINqgP25GXS7Z0dVBmJOzntlQ3hjbHMAU1ExkewWY
printf("Random string: %s", buffer);
delete r;
return 0;
}
如果您正在运行webpack dev服务器,请使用代码段:
webpack --display-error-details
这将在控制台中提供详细的错误报告