我使用angular CLI 7.3.1编写了代码,当我尝试使用ng build
进行构建时,出现以下错误
ERROR in ./node_modules/xhr2-cookies/dist/xml-http-request.js
Module not found: Error: Can't resolve 'http' in '/home/User/Desktop/fy_project_blockchain/angularSwarm/node_modules/xhr2-cookies/dist'
ERROR in ./node_modules/xhr2-cookies/dist/xml-http-request.js
Module not found: Error: Can't resolve 'https' in '/home/User/Desktop/fy_project_blockchain/angularSwarm/node_modules/xhr2-cookies/dist'
我尝试删除xhr2-cookie并重新安装。我也尝试安装http https模块,在xml-http-request.js
文件中提供模块的路径,但仍然给我同样的错误。任何帮助将不胜感激。
答案 0 :(得分:0)
import * as Cookie from 'cookiejar';
XMLHttpRequest.cookieJar = Cookie.CookieJar();
如上使用
答案 1 :(得分:0)
将此添加到您的package.json
文件中
"browser": {
"http": false,
"https": false,
"os": false
}