因为本人刚开始学习某一课程需要用到 nuxt with koa
结果按照githun 安装nuxt with koa,踩了几个掉头发的坑
现在特意写了这个解决的小办法,希望能帮助到大家
- 首先,通过githun 搜索 nuxt with koa,通过npm 安装
vue init nuxt-community/koa-template <project-name>
cd <project-name> # move to your project
//npm install # or yarn install*[see note below]
这里我是使用cnpm来安装
cnpm i
- 然后使用命令 npm run dev 你会发现以下错误
这个我是把"backpack-core": “^0.8.3”,“eslint-loader”: “^2.1.2”,更新到最新
cnpm i backpack-core@latest eslint-loader@latest -D
然后就能编译到下一步
3. 到了这里,安装server 跟 client, server成功了,client发生错误
在这一步,我是安装了core.js
cnpm i core-js@2.6.5 -D
- 然后
npm run dev
,浏览器输入地址localhost:3000
,成功
- 失败原因总结:
首先,依赖不兼容,需要自己手动调解模块到响应的版本
然后,就是缺少模块,需要自己根据信息提示,调试
重点是,自己下载的版本模块,需要将其他模块的版本也一同升级或者降级,不然不兼容,在调试之前,我试过将babel-eslint、backpack-core、core-js、eslint-plugin-html、eslint-loader按照百度把版本都调试了一遍(具体版本我也忘了),虽然能运行,然后出现的问题是,eslint的代码格式问题,因为本人现在还不熟悉eslint语法格式,虽然最后结果能运行,但是报错,所以这里就用一个一个比较笨的办法解决问题是找到nuxt.config.js 文件,把下面代码注释掉
extend (config, ctx) {
if (ctx.isClient) {
config.module.rules.push({
enforce: 'pre',
test: /\.(js|vue)$/,
loader: 'eslint-loader',
exclude: /(node_modules)/
})
}
}