Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yarn workspace下nohoist安装@tarojs/cli 2.0.2, 构建小程序时项目依赖不能被正确检测 #5391

Closed
ccat3z opened this issue Jan 26, 2020 · 2 comments
Assignees

Comments

@ccat3z
Copy link

ccat3z commented Jan 26, 2020

问题描述

yarn workspace下nohoist安装@tarojs/cli 2.0.2, 项目依赖不能被正确检测

复现步骤

example-repo

  1. yarn install
  2. cd packages/test
  3. yarn build:weapp
  4. 警告 依赖安装 项目依赖 @tarojs/taro-weapp 未安装,或安装有误,请重新安装此依赖!

期望行为

能够识别并优先优先使用没有提升安装的包

报错信息

警告 依赖安装 项目依赖 @tarojs/taro-weapp 未安装,或安装有误,请重新安装此依赖!

系统信息

👽 Taro v2.0.2


  Taro CLI 2.0.2 environment info:
    System:
      OS: Linux 4.19 Debian GNU/Linux 10 (buster) 10 (buster)
      Shell: 5.0.3 - /bin/bash
    Binaries:
      Node: 10.18.1 - /tmp/yarn--1580049451783-0.7800912141250702/node
      Yarn: 1.21.1 - /tmp/yarn--1580049451783-0.7800912141250702/yarn
      npm: 6.13.4 - ~/.nvm/versions/node/v10.18.1/bin/npm
    npmPackages:
      @tarojs/components: 2.0.2 => 2.0.2 
      @tarojs/components-qa: 2.0.2 => 2.0.2 
      @tarojs/mini-runner: 2.0.2 => 2.0.2 
      @tarojs/router: 2.0.2 => 2.0.2 
      @tarojs/taro: 2.0.2 => 2.0.2 
      @tarojs/taro-alipay: 2.0.2 => 2.0.2 
      @tarojs/taro-h5: 2.0.2 => 2.0.2 
      @tarojs/taro-qq: 2.0.2 => 2.0.2 
      @tarojs/taro-quickapp: 2.0.2 => 2.0.2 
      @tarojs/taro-rn: 2.0.2 => 2.0.2 
      @tarojs/taro-swan: 2.0.2 => 2.0.2 
      @tarojs/taro-tt: 2.0.2 => 2.0.2 
      @tarojs/taro-weapp: 2.0.2 => 2.0.2 
      @tarojs/webpack-runner: 2.0.2 => 2.0.2 
      eslint-config-taro: 2.0.2 => 2.0.2 
      eslint-plugin-taro: 2.0.2 => 2.0.2 
      nerv-devtools: ^1.5.5 => 1.5.6 
      nervjs: ^1.5.5 => 1.5.6 
      stylelint-config-taro-rn: 2.0.2 => 2.0.2 
      stylelint-taro-rn: 2.0.2 => 2.0.2 

补充信息

export function recursiveFindNodeModules (filePath: string): string {
const dirname = path.dirname(filePath)
const workspaceRoot = findWorkspaceRoot(dirname)
const nodeModules = path.join(workspaceRoot || dirname, 'node_modules')
if (fs.existsSync(nodeModules)) {
return nodeModules
}
if (dirname.split(path.sep).length <= 1) {
printLog(processTypeEnum.ERROR, `在${dirname}目录下`, `未找到node_modules文件夹,请先安装相关依赖库!`)
return nodeModules
}
return recursiveFindNodeModules(dirname)
}

期望支持多个node_modules

Workaround

暂时禁用workspace检测

// @tarojs/cli/dist/util/index.js:319
function recursiveFindNodeModules(filePath) {
    const dirname = path.dirname(filePath);
    const workspaceRoot = undefined // findWorkspaceRoot(dirname);
@taro-bot
Copy link

taro-bot bot commented Jan 26, 2020

CC @luckyadam

@taro-bot
Copy link

taro-bot bot commented Jan 26, 2020

欢迎提交 Issue~

如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏

如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。

Good luck and happy coding~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants