我在我的React应用程序中将babel与webpack一起使用。我已安装满足条件的“ babel-loader”:“ ^ 8.0.5”和“ @ babel / core”:“ ^ 7.4.0”
nil
节点:v10.5.0 npm:v6.1.0
使用guard let viewController = Bundle.main.loadNibNamed("NameOfTheNib", owner: nil, options: nil)?.first else {
print("Can not find nib with that name")
return
}
运行应用程序
支持es6模块
package.json
"babel-loader@8 requires Babel 7.x (the package '@babel/core'). If you'd like to use Babel 6.x ('babel-core'), you should install 'babel-loader@7'".
.babelrc
node --experimental-modules lib/server.mjs
webpack.config.js
{
"name": "advanced-react",
"version": "1.0.0",
"description": "Advanced React",
"main": "lib/server.js",
"author": "Sai",
"license": "MIT",
"scripts": {
"dev": "nodemon --exec babel-node lib/server.mjs",
"webpack": "webpack -wd"
},
"devDependencies": {
"babel-eslint": "^10.0.1",
"eslint": "^5.15.3",
"eslint-plugin-react": "^7.12.4"
},
"dependencies": {
"@babel/cli": "^7.2.3",
"@babel/core": "^7.4.0",
"@babel/plugin-proposal-class-properties": "^7.4.0",
"@babel/polyfill": "^7.4.0",
"@babel/preset-env": "^7.4.2",
"@babel/preset-react": "^7.0.0",
"@babel/preset-stage-2": "^7.0.0",
"@babel/register": "^7.4.0",
"@babel/runtime": "^7.4.2",
"babel-loader": "^8.0.5",
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
"ejs": "^2.6.1",
"express": "^4.16.4",
"react": "^16.8.5",
"react-dom": "^16.8.5",
"webpack": "^4.29.6",
"webpack-cli": "^3.3.0"
}
}
但是当我启动应用程序时遇到此错误
{
"presets": [
"@babel/preset-env",
"@babel/preset-react",
"env",
"react",
"stage-2"
],
"plugins": ["transform-es2015-modules-commonjs"]
}
答案 0 :(得分:0)
答案 1 :(得分:0)
尝试这种变体
npm rebuild node-sass