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:
|