This article is a mirror article of machine translation, please click here to jump to the original article.

View: 3047|Reply: 0

WeChat Mini Program Error: error message Cannot find module 'wx-server-sdk'

[Copy link]
Posted on 5/10/2020 9:12:35 PM | | | |
Using the WeChat Mini Program Development Tool, when clicking "Click to get openid", the console will report the following error:

VM104:1 [云函数] [login] 调用失败 Error: errCode: -404011 cloud function execution error | errMsg: cloud.callFunction:fail requestID 28f186e3-92ac-11ea-83c7-525400a6bef5, cloud function service error code -504002, error message Cannot find module 'wx-server-sdk'; at cloud.callFunction api;
    at new u (WAService.js:1)
    at d (WAService.js:1)
    at f (WAService.js:1)
    at Function.success (WAService.js:1)
    at WAService.js:1
    at C (WAService.js:1)
    at i.<anonymous> (WAService.js:1)
    at i.emit (WAService.js:1)
    at Rs (WAService.js:1)
    at WAService.js:1




The reason for the error is:wx-server-sdk package is not installed

solution

First, install the node.js, open the command line, locate the cloud function directory, and run npm -v and node -v both display the version number

Second, run




If you get an error related to 'Unhandled dejection error, not permitted', you need to open the command line again with administrator privileges and run it again.

If you have multiple cloud functions, you need to run each folder once. After running, package-lock.json files and node_modules folders are created under the folder. And thenRebuild cloud functions。 Then check whether each cloud function in the cloud development console can be successfully called, and you can click Test to test.

For example, right-click Login to create and deploy cloud installation dependencies



Then, try to re-obtain the user openid, and it succeeds as shown in the figure below:







Previous:C# Chinese Chinese characters are converted between simplified and traditional characters
Next:Building electrical installation and construction technology from beginner to proficient
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com