vue-cli: use vue-cli with lerna and got Error: Cannot find module '@vue/cli-plugin-eslint'
Version
4.1.1
Reproduction link
https://github.com/jkhhuse/vue-cli-with-lerna
Environment info
lerna: v3.18.1
vue-cli: 4.1.1
Steps to reproduce
step1: lerna init and lerna.json config:
{
"packages": [
"packages/*"
],
"npmClient": "yarn",
"useWorkspaces": true,
"version": "0.0.1"
}
step2:
use vue-cli create vue project, named vue-based.
step3:
in vue-based directory, execute " yarn run sere", and got error.
What is expected?
run sucess
What is actually happening?
$ yarn run serve
yarn run v1.13.0
$ vue-cli-service serve
internal/modules/cjs/loader.js:583
throw err;
^
Error: Cannot find module '@vue/cli-plugin-eslint'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at idToPlugin (/Users/jk/工程/cmss-project/dm2/node_modules/@vue/cli-service/lib/Service.js:150:14)
at Object.keys.concat.filter.map.id (/Users/jk/工程/cmss-project/dm2/node_modules/@vue/cli-service/lib/Service.js:189:20)
at Array.map (<anonymous>)
at Service.resolvePlugins (/Users/jk/工程/cmss-project/dm2/node_modules/@vue/cli-service/lib/Service.js:175:10)
at new Service (/Users/jk/工程/cmss-project/dm2/node_modules/@vue/cli-service/lib/Service.js:34:25)
at Object.<anonymous> (/Users/jk/工程/cmss-project/dm2/node_modules/@vue/cli-service/bin/vue-cli-service.js:16:17)
error Command failed with exit code 1.
OR
internal/modules/cjs/loader.js:583
throw err;
^
Error: Cannot find module '@vue/cli-plugin-typescript'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at idToPlugin (/Users/jk/工程/learn/vue-cli-with-lerna/node_modules/@vue/cli-service/lib/Service.js:150:14)
at Object.keys.concat.filter.map.id (/Users/jk/工程/learn/vue-cli-with-lerna/node_modules/@vue/cli-service/lib/Service.js:189:20)
at Array.map (<anonymous>)
at Service.resolvePlugins (/Users/jk/工程/learn/vue-cli-with-lerna/node_modules/@vue/cli-service/lib/Service.js:175:10)
at new Service (/Users/jk/工程/learn/vue-cli-with-lerna/node_modules/@vue/cli-service/lib/Service.js:34:25)
at Object.<anonymous> (/Users/jk/工程/learn/vue-cli-with-lerna/node_modules/@vue/cli-service/bin/vue-cli-service.js:16:17)
when copy this vue-cli based project outer of lerna dir, and reinstall node_modules, it can run success. however in lerna packages/vue-based it not work. when copy node_modules in lerna packages/vue-based to lerna root node_modules, yarn run serve run sucess.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 21
- Comments: 17 (3 by maintainers)
Commits related to this issue
- build(yarn): exclude dashboard from workspace to workaround https://github.com/vuejs/vue-cli/issues/4911 — committed to WhatTheFar/senior-proj-backend by WhatTheFar 4 years ago
Thanks for your reply. my solution is:in lerna dir, when use vue-cli to create vue project, don’t select eslint item, and add eslint later. this works but still hope to get an official solution.
The way I fixed this in yarn workspaces was using workspaces nohoist in the root package.json
Here is an error I got with
@vue/cli-service: 4.2.3in a yarn workspace:Lerna + yarn workspace
in root package.json
remove root node_modules &
lerna clean&lerna bootstrapfix itTo get rid of this issue just move the “@vue/cli-plugin-eslint” package from the Vue project package to the root package.json.
This problem is a little bit tricky… For now, the workaround is to use the same semver range of
typescriptin the workspace root and thevue-basedpackage (that is,~3.5.3), so that@vue/cli-plugin-typescriptand@vue/cli-servicecan be hoisted to the same level ofnode_modules.It also works to remove
typescriptfrom devDependencies within your frontend package.A workaround that I use is to create a new package named
sharedwithin the monorepo packages and move @vue/cli + eslint topackages/shared/package.jsonunder dependencies. Then remove duplicates from other packages.3 packages that I haven’t been able to move to a shared level involve sass-loader, vue-cli-plugin-vuetify, and vuetify-loader; which is a Vuetify specific issue.
Same issue. The solution is still to sync your root level
package.jsonwith your package-levelpackage.jsonand re-install dependencies.