Webpack 및 Babel을 사용하는 React 프로젝트가 있습니다. 사무실 컴퓨터에서 만들었을 때, Webpack은 잘 돌아갔습니다. 나는 내 개인 컴퓨터에 프로젝트를 복제 할 때, 다음과 같은 오류 준 :Webpack + Babel : 디렉토리에 상대적인 프리셋 "es2015"를 찾을 수 없습니다.
여기ERROR in ./react_minesweeper.jsx
Module build failed: Error: Couldn't find preset "es2015" relative to directory "/Users/louisstephancruz/Desktop"
at /Users/louisstephancruz/Desktop/w6d5/minesweeper/node_modules/babel-core/lib/transformation/file/options/option-manager.js:298:19
at Array.map (native)
at OptionManager.resolvePresets (/Users/louisstephancruz/Desktop/w6d5/minesweeper/node_modules/babel-core/lib/transformation/file/options/option-manager.js:269:20)
이야 내 webpack.config.js
: 노드의
{
"name": "minesweeper",
"version": "1.0.0",
"description": "",
"main": "webpack.config.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "webpack-dev-server --inline"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"babel": "^6.5.2",
"babel-core": "^6.17.0",
"babel-loader": "^6.2.5",
"babel-preset-es2015": "^6.16.0",
"babel-preset-react": "^6.16.0",
"webpack": "^1.13.2",
"webpack-dev-server": "^1.16.2"
},
"dependencies": {
"react": "^15.3.2",
"react-dom": "^15.3.2"
}
}
내 버전은 다음과 같습니다
여기module.exports = {
entry: './react_minesweeper.jsx',
output: {
path: './',
filename: 'bundle.js',
},
module: {
loaders: [
{
test: [/\.jsx?$/, /\.js?$/],
exclude: /(node_modules)/,
loader: 'babel',
query: {
presets: ['es2015', 'react']
}
}
]
},
devtool: 'source-map',
resolve: {
extensions: ['', '.js', '.jsx' ]
}
};
내가 package.json
입니다 : v5.6.0 내 npm 버전 : 3.6.0
가 묻습니다 : 내 개인 컴퓨터가 엘 카피 탄을 실행 중입니다. (사무용 컴퓨터도 마찬가지라고 생각합니다.) –
오류가'/ Users/louisstephancruz/Desktop'을 참조하면 가정용 데스크톱에'/ Users/louisstephancruz/Desktop/.babelrc' 파일이 있습니까? 그렇다면'node_modules'가'Desktop/w6d5/minesweeper /'가 아닌'Desktop'에있을 것을 기대하기 때문에 프로젝트를 방해 할 수 있습니다. 그'.babelrc'를 지우면 일이 잘될 것입니다. – loganfsmyth
감사합니다. @loganfsmyth .babelrc가 실수로 상위 디렉토리에 있었기 때문에 동일한 오류가 발생했습니다. –