当我运行以下使用babel-node的命令(next.js)时,出现以下问题:
$ npm run dev
> maketube@1.0.0 dev C:\Projects\maketube\frontend
> babel-node server.js --presets es2015,stage-2
C:\Projects\maketube\frontend\node_modules\babel-register\node_modules\babel-core\lib\transformation\file\options\option-manager.js:328
throw e;
^
Error: Plugin 0 specified in "C:\\Projects\\maketube\\frontend\\node_modules\\next\\babel.js" provided an invalid property of "default" (While processing preset: "C:\\Projects\\maketube\\frontend\\node_modules\\next\\babel.js")
at Plugin.init (C:\Projects\maketube\frontend\node_modules\babel-register\node_modules\babel-core\lib\transformation\plugin.js:131:13)
at Function.normalisePlugin (C:\Projects\maketube\frontend\node_modules\babel-register\node_modules\babel-core\lib\transformation\file\options\option-manager.js:152:12)
at C:\Projects\maketube\frontend\node_modules\babel-register\node_modules\babel-core\lib\transformation\file\options\option-manager.js:184:30
at Array.map (<anonymous>)
at Function.normalisePlugins (C:\Projects\maketube\frontend\node_modules\babel-register\node_modules\babel-core\lib\transformation\file\options\option-manager.js:158:20)
at OptionManager.mergeOptions (C:\Projects\maketube\frontend\node_modules\babel-register\node_modules\babel-core\lib\transformation\file\options\option-manager.js:234:36)
at C:\Projects\maketube\frontend\node_modules\babel-register\node_modules\babel-core\lib\transformation\file\options\option-manager.js:265:14
at C:\Projects\maketube\frontend\node_modules\babel-register\node_modules\babel-core\lib\transformation\file\options\option-manager.js:323:22
at Array.map (<anonymous>)
at OptionManager.resolvePresets (C:\Projects\maketube\frontend\node_modules\babel-register\node_modules\babel-core\lib\transformation\file\options\option-manager.js:275:20)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! maketube@1.0.0 dev: `babel-node server.js --presets es2015,stage-2`
不知道该怎么办,所以想知道是否有人可以指导我解决这个令人讨厌的问题。 这是我的package.json:
{
"name": "maketube",
"version": "1.0.0",
"scripts": {
"dev": "babel-node server.js --presets es2015,stage-2",
"build": "next build",
"start": "NODE_ENV=production node server.js"
},
"author": "phil",
"license": "MIT",
"dependencies": {
"autoprefixer": "7.1.5",
"aws-sdk": "^2.213.1",
"axios": "0.15.3",
"babel-cli": "^6.26.0",
"babel-plugin-inline-react-svg": "^0.4.0",
"babel-plugin-module-resolver": "^2.7.1",
"babel-plugin-wrap-in-js": "^1.1.0",
"babel-preset-es2015": "^6.24.1",
"body-parser": "^1.18.2",
"classnames": "^2.2.5",
"cookie-parser": "^1.4.3",
"express": "^4.16.3",
"faker": "^4.1.0",
"glob": "^7.1.2",
"http-proxy-middleware": "^0.17.4",
"jsonwebtoken": "^8.2.0",
"jwt-decode": "^2.2.0",
"lodash": "^4.17.11",
"moment": "^2.21.0",
"net": "^1.0.2",
"next": "latest",
"njwt": "^0.4.0",
"node-sass": "^4.4.0",
"normalize.css": "^7.0.0",
"postcss-easy-import": "^3.0.0",
"postcss-loader": "^2.0.7",
"prop-types": "^15.6.1",
"raw-loader": "^0.5.1",
"react": "^16.5.0",
"react-datepicker": "^0.64.0",
"react-dom": "^16.0.0",
"react-expand-collapse": "^0.2.0",
"react-horizontal-timeline": "^1.4.0",
"sass-loader": "^6.0.6",
"semantic-ui-icon": "^2.2.12",
"semantic-ui-react": "^0.73.0",
"sqlite": "^2.9.0",
"sqlite3": "^3.1.13",
"superagent": "^3.4.0",
"tls": "0.0.1",
"universal-cookie": "^2.1.2"
},
"devDependencies": {
"@babel/core": "^7.1.2",
"babel-core": "^7.0.0-bridge",
"babel-cli": "^6.26.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"now": "^8.3.10"
}
}
和我的babelrc文件:
{
"plugins": [
["inline-react-svg"],
[
"module-resolver", {
"root": ["."],
"alias": {
"styles": "./styles"
},
"cwd": "babelrc"
}],
[
"wrap-in-js",
{
"extensions": ["css$", "scss$"]
}
]
],
"presets": [
"next/babel"
],
"ignore": []
}
我已经尝试了各种操作,例如删除我的node_modules文件夹,然后运行npm install,但是这个令人讨厌的问题仍然存在,到目前为止,我还不知道下一步该怎么做。 Node非常复杂,您必须解决一个问题却遇到另一个问题。
所以希望这里的人对我有一个提示怎么做?
谢谢