nuxt.js 初始化 npm run dev 报错

Posted Xuhua123

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了nuxt.js 初始化 npm run dev 报错相关的知识,希望对你有一定的参考价值。

在初始化 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:UsersLDesktopNuxt
uxt-learn
ode_modulesackpack-coreabel.js
    at createDescriptor (C:UsersLDesktopNuxt
uxt-learn
ode_modules@babelcorelibconfigconfig-descriptors.js:178:11)
    at C:UsersLDesktopNuxt
uxt-learn
ode_modules@babelcorelibconfigconfig-descriptors.js:109:50
    at Array.map (<anonymous>)
    at createDescriptors (C:UsersLDesktopNuxt
uxt-learn
ode_modules@babelcorelibconfigconfig-descriptors.js:109:29)
    at createPresetDescriptors (C:UsersLDesktopNuxt
uxt-learn
ode_modules@babelcorelibconfigconfig-descriptors.js:101:10)
    at C:UsersLDesktopNuxt
uxt-learn
ode_modules@babelcorelibconfigconfig-descriptors.js:58:96
    at cachedFunction (C:UsersLDesktopNuxt
uxt-learn
ode_modules@babelcorelibconfigcaching.js:32:19)
    at presets (C:UsersLDesktopNuxt
uxt-learn
ode_modules@babelcorelibconfigconfig-descriptors.js:29:84)
    at mergeChainOpts (C:UsersLDesktopNuxt
uxt-learn
ode_modules@babelcorelibconfigconfig-chain.js:320:26)
    at C:UsersLDesktopNuxt
uxt-learn
ode_modules@babelcorelibconfigconfig-chain.js:283:7

internal/modules/cjs/loader.js:797
    throw err;
    ^

Error: Cannot find module ‘C:UsersLDesktopNuxt
uxt-learnuildmain.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 <1729792587@qq.com>",
  "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"
  }
}

以上是关于nuxt.js 初始化 npm run dev 报错的主要内容,如果未能解决你的问题,请参考以下文章

npm run dev遇到报错

Vue 项目在其他电脑 npm run dev 运行报错的解决方法

详解Vue项目在其他电脑npm run dev运行报错的解决方法

npm run dev 报错:missing script:dev

使用vue-cli初始化项目时运行‘npm run dev’报错

npm run dev 报错 run `npm audit fix` to fix them, or `npm audit` for details