关于npm install 下载完成后,运行项目报错Module not found: Error: Can't resolve 'tls' in 'D:\frontEnd\node_modules\

ERROR in ./node_modules/request/lib/har.js
Module not found: Error: Can't resolve 'fs' in 'D:\frontEnd\node_modules\request\lib'
 @ ./node_modules/request/lib/har.js 3:9-22
 @ ./node_modules/request/request.js
 @ ./node_modules/request/index.js
 @ ./src/GithubApiService.ts
 @ ./src/index.ts

ERROR in ./node_modules/forever-agent/index.js
Module not found: Error: Can't resolve 'tls' in 'D:\frontEnd\node_modules\forever-agent'
 @ ./node_modules/forever-agent/index.js 7:10-24
 @ ./node_modules/request/request.js
 @ ./node_modules/request/index.js
 @ ./src/GithubApiService.ts
 @ ./src/index.ts

ERROR in ./node_modules/tunnel-agent/index.js
Module not found: Error: Can't resolve 'tls' in 'D:\frontEnd\node_modules\tunnel-agent'
 @ ./node_modules/tunnel-agent/index.js 4:10-24
 @ ./node_modules/request/lib/tunnel.js
 @ ./node_modules/request/request.js
 @ ./node_modules/request/index.js
 @ ./src/GithubApiService.ts
 @ ./src/index.ts
i 「wdm」: Failed to compile.

 

方案1、如果can't resolve 'xxxx' 就安装npm install ‘xxx’就好了,先卸载掉组件npm uninstall ‘xxx’,再进行npm install ‘xxx’,或者是全部删除node_modules文件夹重新 npm install

 

方案2    如果关于fs,tls,net等组件Cant resolve  的情况,该安装的包都安装了但是还是报错,可以尝试在webpack.config.js文件里添加上   

node: {

        fs: 'empty',

        net:'empty',

        tls:"empty",

   }

你可能感兴趣的:(nodejs,typescript)