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

v2.2.3 ===> 引入@tarojs/plugin-mock插件编译错误 #6227

Closed
azhaorz opened this issue May 7, 2020 · 9 comments
Closed

v2.2.3 ===> 引入@tarojs/plugin-mock插件编译错误 #6227

azhaorz opened this issue May 7, 2020 · 9 comments
Assignees

Comments

@azhaorz
Copy link

azhaorz commented May 7, 2020

问题描述

Taro v2.2.3
引入@tarojs/plugin-mock时编译错误

复现步骤

// /config/index.js
const config = {
  ...,
  plugins: [
    [
      '@tarojs/plugin-mock',
      {
        mocks: {
          '/api/mock': {
            name: 'hanzhaorz',
            desc: 'author',
          },
        },
      },
    ],
  ],
  ...
}

期望行为

编译通过,可以使用数据mock

报错信息

(node:74996) UnhandledPromiseRejectionWarning: Error: Cannot find module './dist/index.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:690:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object. (/Users/oliver/Projects/template/taro-template/node_modules/@tarojs/plugin-mock/index.js:1:18)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Module._compile (/Users/oliver/.nvm/versions/node/v10.16.0/lib/node_modules/@tarojs/cli/node_modules/pirates/lib/index.js:99:24)
at Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Object.newLoader [as .js] (/Users/oliver/.nvm/versions/node/v10.16.0/lib/node_modules/@tarojs/cli/node_modules/pirates/lib/index.js:104:7)
at Module.load (internal/modules/cjs/loader.js:653:32)
(node:74996) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:74996) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

系统信息

使用taro info也是同样的报错

补充信息

@taro-bot
Copy link

taro-bot bot commented May 7, 2020

CC @luckyadam

@taro-bot
Copy link

taro-bot bot commented May 7, 2020

欢迎提交 Issue~

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

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

Good luck and happy coding~

@luckyadam
Copy link
Member

遗憾,发出的 @tarojs/plugin-mock 包有点问题,你把它升级到 0.0.4 试试

@azhaorz
Copy link
Author

azhaorz commented May 7, 2020

@luckyadam 升级到0.0.4之后可以使用了,但是每次保存重新编译都会重启服务 端口也会变化
image

@azhaorz
Copy link
Author

azhaorz commented May 7, 2020

@luckyadam 多次保存后就直接报错了
image

@luckyadam
Copy link
Member

了解,看来还是插件写得有点问题,待我再更新一个版本

@luckyadam
Copy link
Member

NervJS/taro-plugin-mock@8af10cd
可以升级到 0.0.5 试试

@azhaorz
Copy link
Author

azhaorz commented May 7, 2020

可以了 完美 大佬🐂🍺

@luckyadam
Copy link
Member

OJBK

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