How to generate the miniprogram_npm folder in WeChat applet (detailed explanation)

Encounter problems

miniprogram_npmWhen the vant component was introduced into the mini program, a folder was not found in the directory , resulting in vant not being introduced successfully.

Solution

vant introduce half, try,

Build npm first, then continue to introduce vant

Sure enough, after building npm, miniprogram_npmthe folder was generated and vant was introduced successfully.
Insert image description here

Found out later

In the applet project, it is generated miniprogram_npm目录by using commands. npm installThis directory stores third-party dependent libraries installed through npm.

To upgrade the mini program version and automatically generate the miniprogram_npm directory, you can follow the steps below :

  1. Make sure there is a valid file in your applet project directory package.json. npm initIf not, you can create a new file by executing in the project root directory package.json.
  2. .In the project 根目录下执行命令npm install, this will install the required third-party packages into the node_modules directory based on the dependency list in the package.json file.
  3. In the mini program development tool, click in the menu bar “工具”-“构建 npm”, which will automatically node_modulescopy the dependencies in to the directory under the root directory of the mini program miniprogram_npm.
  4. After confirming miniprogram_npmthat the directory has been generated, you can use the third-party library installed through npm in the applet code.

tips

Please note that this is required after each npm install 重新执行一次“构建 npm”to copy the latest dependencies into miniprogram_npmthe directory.

Guess you like

Origin blog.csdn.net/Maxueyingying/article/details/135123110