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

编译配置添加本地 plugin 编译时 Cannot find module #7222

Open
afishhhhh opened this issue Jul 31, 2020 · 5 comments
Open

编译配置添加本地 plugin 编译时 Cannot find module #7222

afishhhhh opened this issue Jul 31, 2020 · 5 comments
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-2 Version - 2.x

Comments

@afishhhhh
Copy link

相关平台

微信小程序

小程序基础库: 2.7.3
使用框架: React

复现步骤

路径:项目根目录/plugin/plugin-demo/index.js

// index.js
export default ctx => {
  // plugin 主体
  ctx.onBuildStart(() => {
    console.log('编译开始!')
  })
  ctx.onBuildFinish(() => {
    console.log('编译结束!')
  })
}

// config/index.js
const config = {
  // ...
  plugins: [
    '@tarojs/plugin-sass',
    '@tarojs/plugin-uglify',
    '/plugin/plugin-demo'
  ]
}

期望结果

编译成功

实际结果

Cannot find module 'plugin/plugin-demo' from ...

环境信息

Taro CLI 2.2.11 environment info:
    System:
      OS: macOS 10.14.6
      Shell: 5.3 - /bin/zsh
    Binaries:
      Node: 14.4.0 - /usr/local/bin/node
      npm: 6.14.4 - /usr/local/bin/npm
    npmPackages:
      @tarojs/components: 2.2.11 => 2.2.11 
      @tarojs/components-qa: 2.2.11 => 2.2.11 
      @tarojs/mini-runner: 2.2.11 => 2.2.11 
      @tarojs/plugin-sass: 2.2.11 => 2.2.11 
      @tarojs/plugin-uglify: 2.2.11 => 2.2.11 
      @tarojs/router: 2.2.11 => 2.2.11 
      @tarojs/taro: 2.2.11 => 2.2.11 
      @tarojs/taro-alipay: 2.2.11 => 2.2.11 
      @tarojs/taro-h5: 2.2.11 => 2.2.11 
      @tarojs/taro-qq: 2.2.11 => 2.2.11 
      @tarojs/taro-quickapp: 2.2.11 => 2.2.11 
      @tarojs/taro-rn: 2.2.11 => 2.2.11 
      @tarojs/taro-swan: 2.2.11 => 2.2.11 
      @tarojs/taro-tt: 2.2.11 => 2.2.11 
      @tarojs/taro-weapp: 2.2.11 => 2.2.11 
      @tarojs/webpack-runner: 2.2.11 => 2.2.11 
      eslint-config-taro: 2.2.11 => 2.2.11 
      eslint-plugin-taro: 2.2.11 => 2.2.11 
      nerv-devtools: ^1.5.7 => 1.5.7 
      nervjs: ^1.5.7 => 1.5.7 
      stylelint-config-taro-rn: 2.2.11 => 2.2.11 
      stylelint-taro-rn: 2.2.11 => 2.2.11 
      taro-ui: ^2.3.2 => 2.3.2 
@taro-bot2 taro-bot2 bot added F-react Framework - React T-weapp Target - 编译到微信小程序 V-2 Version - 2.x labels Jul 31, 2020
@afishhhhh
Copy link
Author

@luckyadam 请问这个插件路径有什么问题吗?按文档写的绝对路径啊

@GONDON
Copy link

GONDON commented Dec 9, 2020

@luckyadam 请问这个插件路径有什么问题吗?按文档写的绝对路径啊

你解决了吗? 我也遇到这个问题了

@FE-Mars
Copy link

FE-Mars commented Apr 12, 2021

你解决了吗? 我也遇到这个问题了

@bluekurk
Copy link

bluekurk commented Apr 23, 2021

@luckyadam 请问这个插件路径有什么问题吗?按文档写的绝对路径啊

const path = require("path");
然后
path.resolve(/plugin/plugin-demo),
或者
path.resolve(/plugin/plugin-demo/index.js),

试试

@LDmin
Copy link

LDmin commented Jun 23, 2021

这种路径试试/Users/xxxx/myApp/plugins/test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-2 Version - 2.x
Projects
None yet
Development

No branches or pull requests

5 participants