在初始化 npm install 了基本依赖后; npm run dev 报错:
error in ./server/index.js Module build failed: Error: Plugin/Preset files are not allowed to export objects, only functions. In C:\Users\L\Desktop\Nuxt\nuxt-learn\node_modules\backpack-core\babel.js at createDescriptor (C:\Users\L\Desktop\Nuxt\nuxt-learn\node_modules\@babel\core\lib\config\config-descriptors.js:178:11) at C:\Users\L\Desktop\Nuxt\nuxt-learn\node_modules\@babel\core\lib\config\config-descriptors.js:109:50 at Array.map (<anonymous>) at createDescriptors (C:\Users\L\Desktop\Nuxt\nuxt-learn\node_modules\@babel\core\lib\config\config-descriptors.js:109:29) at createPresetDescriptors (C:\Users\L\Desktop\Nuxt\nuxt-learn\node_modules\@babel\core\lib\config\config-descriptors.js:101:10) at C:\Users\L\Desktop\Nuxt\nuxt-learn\node_modules\@babel\core\lib\config\config-descriptors.js:58:96 at cachedFunction (C:\Users\L\Desktop\Nuxt\nuxt-learn\node_modules\@babel\core\lib\config\caching.js:32:19) at presets (C:\Users\L\Desktop\Nuxt\nuxt-learn\node_modules\@babel\core\lib\config\config-descriptors.js:29:84) at mergeChainOpts (C:\Users\L\Desktop\Nuxt\nuxt-learn\node_modules\@babel\core\lib\config\config-chain.js:320:26) at C:\Users\L\Desktop\Nuxt\nuxt-learn\node_modules\@babel\core\lib\config\config-chain.js:283:7 internal/modules/cjs/loader.js:797 throw err; ^ Error: Cannot find module 'C:\Users\L\Desktop\Nuxt\nuxt-learn\build\main.js' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:794:15) at Function.Module._load (internal/modules/cjs/loader.js:687:27) at Function.Module.runMain (internal/modules/cjs/loader.js:1025:10) at internal/main/run_main_module.js:17:11 { code: 'MODULE_NOT_FOUND', requireStack: [] }
初始化的 依赖中 版本都比较旧,只需将下面红色部分版本手动升级即可。
{ "name": "nuxt-learn", "version": "1.1.0", "description": "Nuxt.js project", "author": "Xuhua <[email protected]>", "private": true, "scripts": { "dev": "backpack dev", "build": "nuxt build && backpack build", "start": "cross-env NODE_ENV=production node build/main.js", "precommit": "npm run lint", "lint": "eslint --ext .js,.vue --ignore-path .gitignore ." }, "dependencies": { "cross-env": "^5.0.1", "koa": "^2.4.1", "nuxt": "latest", "source-map-support": "^0.4.15" }, "devDependencies": { "babel-eslint": "^7.1.1", "backpack-core": "^0.8.4", "eslint": "^3.19.0", "eslint-config-standard": "^10.2.1", "eslint-loader": "^2.1.1", "eslint-plugin-html": "^2.0.3", "eslint-plugin-import": "^2.2.0", "eslint-plugin-node": "^4.2.2", "eslint-plugin-promise": "^3.4.0", "eslint-plugin-standard": "^3.0.1", "nodemon": "^1.11.0", "scmp": "^2.0.0" } }