Umi: 执行yarn start报错 Error: Cannot find module 'ajv/lib/compile/equal'

Created on 29 Nov 2018  ·  6Comments  ·  Source: umijs/umi

首次使用umi框架,首先谢谢提供一个这么方便的框架。

系统:osx 10.13.6 (17G65)
npm版本: 6.4.1
node版本:8.12.0
yarn版本:1.12.3

按照官网指南的"通过脚手架创建项目"章节步骤操作,功能选择了全部,执行yarn命令,依赖包提示全部安装成功,然后执行yarn start控制台报错:

`
xiecp@macdeMacBook-Pro  ~/plaque/my-app  yarn start
yarn run v1.12.3
$ umi dev
module.js:550
throw err;
^

Error: Cannot find module 'ajv/lib/compile/equal'
at Function.Module._resolveFilename (module.js:548:15)
at Function.Module._load (module.js:475:25)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object. (/Users/xiecp/plaque/my-app/node_modules/webpackbar/node_modules/table/dist/validateConfig.js:2:13)
at Module._compile (module.js:653:30)
at Module._compile (/Users/xiecp/plaque/my-app/node_modules/pirates/lib/index.js:83:24)
at Module._extensions..js (module.js:664:10)
at Object.newLoader [as .js] (/Users/xiecp/plaque/my-app/node_modules/pirates/lib/index.js:88:7)
at Module.load (module.js:566:32)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
`

查看了类似的issue,尝试过多次删除node_modules,重新执行yarn命令,然后执行yarn start依然报错,错误同上。

也试过局部安装ajv包和全局安装ajv包,安装后执行yarn start依然报错,错误同上。

希望能得到一些解决的方法,供我尝试解决这个问题,目的是成功把项目跑起来,非常感谢!

Most helpful comment

解决方案

  1. 修改 package.json,加上 "resolutions": {"ajv": "@6.5.5"}

  2. 再执行一遍 yarn install 或者 npm install

理论上,重启 umi dev 就正常了。

参考

All 6 comments

解决方案

  1. 修改 package.json,加上 "resolutions": {"ajv": "@6.5.5"}

  2. 再执行一遍 yarn install 或者 npm install

理论上,重启 umi dev 就正常了。

参考

npm install 就可以了 yarn install 再 start 是有问题的

谢谢!在package.json加上"resolutions": {"ajv": "6.5.5"},再yarn安装依赖,然后start就可以了。

今天再用yarn create umi命令初始化项目,已经不会报错了。

最简单的demo还是不行, 是否需要更新文档?
@sorrycc

# Install deps
$ yarn global add umi # OR npm install -g umi

# Create application
$ mkdir myapp && cd myapp

# Create page
$ umi generate page index

# Start dev server
$ umi dev

# Build and deploy
$ umi build
Was this page helpful?
0 / 5 - 0 ratings

Related issues

Artoria-0x04 picture Artoria-0x04  ·  3Comments

six-666 picture six-666  ·  3Comments

haiing picture haiing  ·  3Comments

afc163 picture afc163  ·  3Comments

zemzheng picture zemzheng  ·  3Comments