我正在通过React教程,在设置过程中出现空白屏幕。当我运行npm start时,我只得到一个空白的白色屏幕,但是当我检查元素时,我可以看到空白的div。
I found a similar issue here but the solution doesn't work for me
我得到1个错误:babel的节点API已移至babel-core。 @ multi main
我已经复制了github文件中的所有确切文件,这仍然是我得到的。
我已经尝试过npm uninstall babel -g但它仍然会出现相同的错误和白屏。
这是我的webpack.config.js
module.exports = {
entry: './main.js',
output: {
path: './',
filename: 'index.js'
},
devServer: {
inline: true,
port: 3333
},
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel',
query: {
presets: ['es2015', 'react']
}
}
]
}
}
这是我的package.json
{
"name": "es6-react-setup",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"start": "webpack-dev-server"
},
"author": "",
"license": "ISC",
"dependencies": {
"babel-core": "^6.2.1",
"babel-loader": "^6.2.0",
"babel-preset-es2015": "^6.1.18",
"babel-preset-react": "^6.1.18",
"react": "^0.14.3",
"react-dom": "^0.14.3"
},
"description": "Setup files for React in ES6 lessons"
}
答案 0 :(得分:0)
我尝试删除node_modules并重新安装所有依赖项,这对我有用。
我认为现在这篇文章的重复:Using webpack with babel and babel-preset-react and babel-preset-es2015