Error: Cannot find module 'pg', after running npm install pg
Error: Cannot find module 'pg', after running npm install pg
使用VSCode。为 Windows 安装了最新的 Node.js(第一次使用)和所需的模块,其中一个是 'pg' (npm install pg)
在我的脚本顶部我有这个:
const pg = require('pg');
当我尝试调试时,遇到该行时出现此错误:
Exception has occurred: Error
Error: Cannot find module 'pg'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (c:\EBI\Work\Node-pg-log\get_pg_log.js:3:12)
at Module._compile (module.js:649:14)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
我还需要安装或设置其他东西吗?调试到位
当 node_modules/
文件夹位于某个子目录中时,通常会发生这种情况。喜欢
/app
----index.js
----/libs
--------/node_modules/
你想要一个像
这样的目录结构
/app
----index.js
----node_modules/
其中 node_modules
文件夹在当前目录或某个上层目录中
使用VSCode。为 Windows 安装了最新的 Node.js(第一次使用)和所需的模块,其中一个是 'pg' (npm install pg)
在我的脚本顶部我有这个:
const pg = require('pg');
当我尝试调试时,遇到该行时出现此错误:
Exception has occurred: Error
Error: Cannot find module 'pg'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (c:\EBI\Work\Node-pg-log\get_pg_log.js:3:12)
at Module._compile (module.js:649:14)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
我还需要安装或设置其他东西吗?调试到位
当 node_modules/
文件夹位于某个子目录中时,通常会发生这种情况。喜欢
/app
----index.js
----/libs
--------/node_modules/
你想要一个像
这样的目录结构/app
----index.js
----node_modules/
其中 node_modules
文件夹在当前目录或某个上层目录中