使用mysql2連接時報了個錯
image.png
Cannot read properties of undefined (reading 'createConnection')
寫法是按照官網文檔處寫的
image.png
解決
看報錯是因為import 的mysql是undefined導致的
所以import的寫法官網文檔是錯的
改成下面的就可以了
import * as mysql from 'mysql2/promise';
使用mysql2連接時報了個錯
Cannot read properties of undefined (reading 'createConnection')
寫法是按照官網文檔處寫的
看報錯是因為import 的mysql是undefined導致的
所以import的寫法官網文檔是錯的
改成下面的就可以了
import * as mysql from 'mysql2/promise';