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

stylelint-taro-rn 找不到文件 stylelint\lib\utils\declarationValueIndex.cjs #17144

Open
prot3in opened this issue Jan 4, 2025 · 3 comments

Comments

@prot3in
Copy link

prot3in commented Jan 4, 2025

相关平台

React Native

使用框架: React

复现步骤

  1. 使用taro init正常创建项目,项目模板使用从github拉取的react-native,安装依赖,yarn dev:rn,使用taro app扫码。
  2. 此时,控制台在构建项目时会报错:error: src\app.css: Cannot find module '{projectPath}\node_modules\.pnpm\[email protected][email protected]\node_modules\stylelint\lib\utils\declarationValueIndex.cjs' imported from {projectPath}\node_modules\.pnpm\[email protected][email protected]\node_modules\stylelint-taro-rn\dist\index.esm.js

期望结果

项目构建成功正常启动

实际结果

由于stylelint-taro-rn找不到stylelint\lib\utils\declarationValueIndex.cjs文件,导致项目启动失败。

环境信息

Taro CLI 4.0.8 environment info:
    System:
      OS: Windows 11 10.0.22631
    Binaries:
      Node: 18.18.2 - D:\node16\node.EXE
      Yarn: 1.22.22 - D:\node\npm_global\yarn.CMD
      npm: 9.8.1 - D:\node16\npm.CMD
    npmPackages:
      @tarojs/cli: 4.0.8 => 4.0.8
      @tarojs/components: 4.0.8 => 4.0.8
      @tarojs/components-rn: 4.0.8 => 4.0.8
      @tarojs/helper: 4.0.8 => 4.0.8
      @tarojs/plugin-framework-react: 4.0.8 => 4.0.8
      @tarojs/plugin-platform-alipay: 4.0.8 => 4.0.8
      @tarojs/plugin-platform-h5: 4.0.8 => 4.0.8
      @tarojs/plugin-platform-jd: 4.0.8 => 4.0.8
      @tarojs/plugin-platform-qq: 4.0.8 => 4.0.8
      @tarojs/plugin-platform-swan: 4.0.8 => 4.0.8
      @tarojs/plugin-platform-tt: 4.0.8 => 4.0.8
      @tarojs/plugin-platform-weapp: 4.0.8 => 4.0.8
      @tarojs/react: 4.0.8 => 4.0.8
      @tarojs/rn-runner: 4.0.8 => 4.0.8
      @tarojs/rn-supporter: 4.0.8 => 4.0.8
      @tarojs/runtime: 4.0.8 => 4.0.8
      @tarojs/runtime-rn: 4.0.8 => 4.0.8
      @tarojs/shared: 4.0.8 => 4.0.8
      @tarojs/taro: 4.0.8 => 4.0.8
      @tarojs/taro-loader: 4.0.8 => 4.0.8
      @tarojs/taro-rn: 4.0.8 => 4.0.8
      @tarojs/webpack5-runner: 4.0.8 => 4.0.8
      babel-preset-taro: 4.0.8 => 4.0.8
      eslint-config-taro: 4.0.8 => 4.0.8
      expo: ~50.0.21 => 50.0.21
      react: ^18.2.0 => 18.2.0
      react-native: ^0.73.1 => 0.73.1

补充信息

问题分析:在stylelint-taro-rnpackage.json中,依赖项stylelint的版本为^16.4.0,所以安装依赖时会安装最新版16.12.0,而文件stylelint\lib\utils\declarationValueIndex.cjsstylelint 16.11.0后被移除。

临时解决办法:在node_modules对应位置手动添加旧版本的declarationValueIndex.cjs,项目即可正常启动。

可能的解决方案:修改stylelint-taro-rn项目的package.json,将stylelint版本从^16.4.0改为>=16.4.0 <=16.10.0

@itneste
Copy link

itneste commented Jan 5, 2025

我也遇到了这个问题,的确是stylelint升级导致的,但我把版本降到存在这个文件的版本16.4.x,重新yarn start,依然提示找不到这个文件,但node modules目录中确认已经有了。不知道是否哪里还有缓存?

@prot3in
Copy link
Author

prot3in commented Jan 5, 2025

我也遇到了这个问题,的确是stylelint升级导致的,但我把版本降到存在这个文件的版本16.4.x,重新yarn start,依然提示找不到这个文件,但node modules目录中确认已经有了。不知道是否哪里还有缓存?

改自己项目依赖的sytlelint没用,因为报错的引用路径是node_modules -> stylelint-taro-rn -> node_modules -> stylelint而不是node_modules -> stylelint,所以我在 '\node_modules\.pnpm\[email protected][email protected]\node_modules\stylelint\lib\utils\'位置手动添加了旧版本的declarationValueIndex.cjs,这样项目就正常启动了

@itneste
Copy link

itneste commented Jan 6, 2025

我也遇到了这个问题,的确是stylelint升级导致的,但我把版本降到存在这个文件的版本16.4.x,重新yarn start,依然提示找不到这个文件,但node modules目录中确认已经有了。不知道是否哪里还有缓存?

改自己项目依赖的sytlelint没用,因为报错的引用路径是node_modules -> stylelint-taro-rn -> node_modules -> stylelint而不是node_modules -> stylelint,所以我在 '\node_modules\.pnpm\[email protected][email protected]\node_modules\stylelint\lib\utils\'位置手动添加了旧版本的declarationValueIndex.cjs,这样项目就正常启动了

是这样的

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

2 participants