我收到了一个babel-node错误。请帮我解决这个问题。
请参阅下面的错误
enter code here
root@ip-10-252-14-11:/home/ubuntu/workarea/sourcecode/ntdl# babel-node
node/react-render.jsx
/usr/local/lib/node_modules/@babel/core/node_modules/@babel/template/lib/builder.js:86 扔错了; ^
错误:给出了未知的替换“BODY” 在/usr/local/lib/node_modules/@babel/core/node_modules/@babel/template/lib/populate.js:22:15 在Array.forEach() 在populatePlaceholders(/usr/local/lib/node_modules/@babel/core/node_modules/@babel/template/lib/populate.js:20:31) 在/usr/local/lib/node_modules/@babel/core/node_modules/@babel/template/lib/string.js:20:51 在/usr/local/lib/node_modules/@babel/core/node_modules/@babel/template/lib/builder.js:83:14 在规范(/home/ubuntu/workarea/sourcecode/ntdl/node_modules/babel-plugin-transform-es2015-for-of/lib/index.js:159:20) 在PluginPass.ForOfStatement(/home/ubuntu/workarea/sourcecode/ntdl/node_modules/babel-plugin-transform-es2015-for-of/lib/index.js:72:21) at newFn(/usr/local/lib/node_modules/@babel/core/node_modules/@babel/traverse/lib/visitors.js:223:21) 在NodePath._call上(/usr/local/lib/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:64:19) 在NodePath.call上(/usr/local/lib/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:38:17) ============= 在exports.default(/home/ubuntu/workarea/sourcecode/ntdl/node_modules/babel-plugin-transform-es2015-for-of/lib/index.js:11:20) 在/usr/local/lib/node_modules/@babel/core/lib/config/index.js:167:14 在cachedFunction(/usr/local/lib/node_modules/@babel/core/lib/config/caching.js:40:17) at loadPluginDescriptor(/usr/local/lib/node_modules/@babel/core/lib/config/index.js:202:28) 在/usr/local/lib/node_modules/@babel/core/lib/config/index.js:59:16 在Array.map() 在recurseDescriptors(/usr/local/lib/node_modules/@babel/core/lib/config/index.js:58:36) 在recurseDescriptors(/usr/local/lib/node_modules/@babel/core/lib/config/index.js:92:27)
我的babel-node版本是
root @ ip-10-252-14-11:/ home / ubuntu / workarea / sourcecode / ntdl#babel-node --version 7.0.0-beta.40
我的package.json文件内容是
{
"name": "ntdl",
"version": "1.0.2",
"description": "Build and rendering server for NTDL django project",
"license": "SEE LICENSE IN license.txt",
"devDependencies": {
"babel-eslint": "^6.1.2",
"cssmin": "^0.4.3",
"eslint": "^3.11.1",
"eslint-plugin-react": "^6.8.0",
"uglify": "^0.1.5"
},
"scripts": {
"start": "concurrently --no-color \"npm run pack\" \"npm run django\"
\"npm run render\"",
"partial-start": "concurrently --no-color \"npm run pack\" \"npm run
render\"",
"start-prod": "concurrently --no-color \"uwsgi --ini
/home/ntdl/code/uwsgi.ini\" \"nginx\" \"npm run render-prod\"",
"pack": "webpack --watch --config node/webpack/webpack.config.js",
"pack-prod": "webpack --config node/webpack/webpack.production.config.js",
"django": "python manage.py runserver",
"render": "babel-node node/react-render.jsx --watch",
"render-prod": "babel-node node/react-render.jsx",
"pylint": "pylint ntdl cms search",
"eslint": "eslint static/style/style.js && eslint --ext .jsx search",
"lint": "npm run pylint && npm run eslint",
"es-index": "babel-node elasticsearch/index/create.js",
"migratedb": "python manage.py migrate"
},
"dependencies": {
"autobind-decorator": "^2.1.0",
"babel-cli": "^7.0.0-alpha.20",
"babel-core": "^7.0.0-alpha.20",
"babel-loader": "^7.1.2",
"babel-plugin-transform-decorators-legacy": "1.3.4",
"babel-plugin-transform-object-rest-spread": "^7.0.0-alpha.20",
"babel-plugin-transform-optional-chaining": "^7.0.0-alpha.20",
"babel-polyfill": "^6.23.0",
"babel-preset-env": "^2.0.0-alpha.20",
"babel-preset-react": "^7.0.0-alpha.20",
"babel-register": "^7.0.0-alpha.20",
"body-parser": "^1.17.2",
"concurrently": "^3.5.0",
"elasticsearch": "^12.1.3",
"express": "^4.15.4",
"history": "^4.7.2",
"material-ui": "^0.16.7",
"node-sass": "^3.13.0",
"openseadragon": "^2.3.0",
"pdfjs-dist": "^1.8.492",
"query-string": "^5.0.0",
"react": "^15.6.1",
"react-dom": "^15.6.1",
"react-redux": "^5.0.6",
"react-render": "^1.2.1",
"react-router": "^4.2.0",
"react-router-dom": "^4.2.2",
"react-router-redux": "^5.0.0-alpha.6",
"react-tap-event-plugin": "^2.0.1",
"redux": "^3.7.2",
"redux-thunk": "^2.2.0",
"request": "2.79.0",
"webpack": "^3.5.5",
"webpack-bundle-tracker": "0.1.0",
"yargs": "^6.6.0"
}
}
我的.babelrc文件内容是
{
"presets": [
"react",
["env", {
"targets": {
"browsers": ["last 2 versions", "ie >= 11"],
"node": "current"
}
}]
],
"plugins": [
"transform-decorators-legacy",
"transform-optional-chaining",/
"transform-object-rest-spread"
]
}
请告诉我如何解决此错误。并指导我使用babel的最佳实践
babel-core与@ babel / core有什么区别?请通过一些指示。
非常感谢,
Bharath AK
答案 0 :(得分:0)
首先尝试删除package-lock.json
,然后运行npm update
使用npm install --save-dev babel-core