2017-04-16 1 views
0

webpack에서이 오류가 계속 발생하고 webpack --display-error-details을 실행해도 오류가 발생하지 않습니다. 하지만 언제든지 나는 webpack-dev-server을 실행하면 다음 오류가 발생합니다. 나는 나의 구성에서 내가 어디로 잘못 가고 있는지 정말로 볼 수 없다. webpack에서 '파일'오류를 해결할 수 없습니다?

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' ] 
    } 
}; 


Entry module not found: Error: Cannot resolve 'file' or 'directory' 
./frontend/app.jsx 

웹팩가 당신이 그것을 원하는대로 __dirname 치료되지 않을 수 있습니다 대신 /로 해결 할 수있다
{ 
    "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

안녕하세요, 폴더 구조는 무엇입니까? ./frontend/app.jsx라는 파일이 컨텍스트와 동일한 폴더에없는 것 같습니다. __dirname –

답변

0

. 시도하여 웹팩 설정이 추가 : 당신이 웹팩 2를 실행하는 경우

:

{ 
    node: { 
    __dirname: true 
    } 
} 
0

이 때문에 여러 이유로 정확한 문제를 파악하는 가장 좋은 방법이 될 수는 두 명령 아래를 적격 심사하는 것입니다

webpack-dev-server --display-error-details 
: 당신이 웹팩 dev에 서버가 다음 코드 조각을 사용하여 실행하는 경우

webpack --display-error-details 

: 혼자 다음 코드 조각을 사용하여

이렇게하면 콘솔에 자세한 오류 보고서가 표시됩니다.

관련 문제