When building npm, the error NPM packages not found. Please confirm npm packages which need to build are belong to miniprogramRoot directory…
This article introduces the method of "How to build npm for the WeChat Mini Program TS project".
Release time of this article: 2023.05.25
project environment
Windows10
npm9.6.7
WeChat Developer Tools Stable 1.06.2303220
TS WeChat Mini Program Project
error message
as shown in the picture
Solution
-
First, we create a TS project for a WeChat applet.
-
Right-click in the project directory - click [Open in an external terminal window]
-
In the cmd window that opens, enter the command
npm init -y
-
Re-enter the command
npm install
-
project.config.json
Add the following configuration to the file"packNpmManually": true, "packNpmRelationList": [ { "packageJsonPath": "./package.json", "miniprogramNpmDistDir": "./miniprogram/" } ],
-
At this time, don't rush to click [Build npm], but click [Reopen this project] first.
-
Wait for the project to reopen, and then click [Build npm].
-
You can build successfully!