我已經按照不同的開發者發佈的stackoverflow帖子上的解決方案。但是,他們都沒有幫助解決我遇到的問題。少數人的事情,我確實是Webpack與巴貝爾失敗已被轉移到巴貝爾核心
- 卸載通天
- 安裝通天核心,巴貝爾-CLI
- 升級爲節點V6.2.2
- 重裝的WebPack
- 炸燬了node_modules就跑NPM安裝再次
上述所有的永遠定格這個錯誤
ERROR in The node API for `babel` has been moved to `babel-core`.
@ (webpack)-dev-server/client?http://localhost:3333 1:10-24
ERROR in The node API for `babel` has been moved to `babel-core`.
@ (webpack)-dev-server/client?http://localhost:3333 3:16-37
ERROR in The node API for `babel` has been moved to `babel-core`.
@ (webpack)-dev-server/client?http://localhost:3333 2:13-37
ERROR in (webpack)/~/process/browser.js
Module build failed: Error: Couldn't find preset "react" relative to directory "/Users/admin/.nvm/versions/node/v6.0.0/lib/node_modules/webpack/node_modules/process"
at /Users/admin/repos/ReactJSApps/react-es6-setup/node_modules/babel-core/lib/transformation/file/options/option-manager.js:395:17
at Array.map (native)
.
.
.
webpack: bundle is now VALID.
這裏是我的package.json
{
"name": "react-es6-setup",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "webpack-dev-server"
},
"author": "",
"license": "ISC",
"dependencies": {
"react": "^15.2.0",
"react-dom": "^15.2.0"
},
"devDependencies": {
"babel-core": "^6.10.4",
"babel-loader": "^6.2.4",
"babel-preset-es2015": "^6.9.0",
"babel-preset-react": "^6.11.1"
}
}
而且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' ]
}
}
]
}
}
和node_modules的DIR上市
$ ls -l node_modules/ |grep react
drwxr-xr-x 6 admim 207825898 204 Jul 6 02:02 babel-helper-builder-react-jsx/
drwxr-xr-x 6 admim 207825898 204 Jul 6 02:02 babel-plugin-transform-react-display-name/
drwxr-xr-x 6 admim 207825898 204 Jul 6 02:02 babel-plugin-transform-react-jsx/
drwxr-xr-x 6 admim 207825898 204 Jul 6 02:02 babel-plugin-transform-react-jsx-self/
drwxr-xr-x 6 admim 207825898 204 Jul 6 02:02 babel-plugin-transform-react-jsx-source/
drwxr-xr-x 6 admim 207825898 204 Jul 6 02:02 babel-preset-react/
drwxr-xr-x 9 admim 207825898 306 Jul 6 02:03 react/
drwxr-xr-x 9 admim 207825898 306 Jul 6 02:03 react-dom/
我沒有看到的WebPack在你的package.json,你安裝它沒有NPM,或全球? –
我全局安裝了它。這是我做的,它修復了它。我卸載了它,並沒有再使用-g。我剛剛添加了--save-dev。有什麼不同? – devwannabe
我的第一個想法是,您使用的是舊版本的webpack,所以我想查看package.json中的版本並注意到它不在那裏。我不確定它爲什麼現在能夠正常工作,除非您使用的以前版本有問題。很高興它是固定的! –