插件开发如何正确引入npm?

发布于 6 年前作者 pingpeng2216 次浏览最后编辑 6 年前来自 ask

如下图,在插件中安装了npm-moment包,引入的时候报错了,看了下别的问题是要放在plugin目录下,

可是还是报错。。

1 回复
lmeng
lmeng1 楼4 年前

已解决,require时需要用相对路径,

const moment = require(‘…/miniprogram_npm/moment/index.js’)