在blog-express中调试的问题
来源:10-7 express开发博客项目-初始化环境
慕设计9348276
2019-07-17
希望在blog-express中调试,把blog-express的名字都改成了backend, 点击调试后出现错误,c:\backend\node_modules\mysql\lib\ConnectionConfig.js:12
this.host = options.host || ‘localhost’; TypeError: Cannot read property ‘host’ of undefined,百思不得其解,在laungch.json中已经 配置 “program”: “${workspaceFolder}/backend/app.js”,也在package.json将name改为backend了,但是调试就是出现上面的错误,用npm run dev是可以正常运行的,请教老师这个问题如何解决呢?或者解决思路应该是什么,谢谢。
2回答
-
首先,你要复现 Cannot read property ‘host’ of undefined 这个 bug ,这个提示就是说 options === undefined 。
其次,你要去排查为何 options 是 undefined ?找一下它是哪里定义的?如何一步一步赋值的?最终就能找到为何是 undefined 。
022019-07-17 -
慕设计9348276
提问者
2019-07-18
详细错误信息如下:
c:\mywork\backend\node_modules\mysql\lib\ConnectionConfig.js:12
this.host = options.host || 'localhost';
^
TypeError: Cannot read property 'host' of undefined
at new ConnectionConfig (c:\mywork\backend\node_modules\mysql\lib\ConnectionConfig.js:12:37)
at Object.createConnection (c:\mywork\backend\node_modules\mysql\index.js:13:34)
at Object.<anonymous> (c:\mywork\backend\db\mysql.js:5:19)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:690:17)
at require (internal/modules/cjs/helpers.js:25:18)
Waiting for the debugger to disconnect...
鼠标放到require那条语句上提示:无法找到模块“./protocol/constants/client”的声明文件。“c:/mywork/backend/node_modules/mysql/lib/protocol/constants/client.js”隐式拥有 "any" 类型。ts(7016)
062019-07-18
相似问题