工作中的第一个项目在 Ubuntu 上遇到了这个繁琐的错误。
\n\n目前使用node -v 13.8.0,安装了python 2.7.17,GCC 7.5.0
\n\n还检查了 node-gyp npm 页面并安装了所有 python 和 gcc 依赖项。\n这是我的 package.json 文件
\n\n "dependencies": {\n "apn": "^2.1.5",\n "async": "^1.5.2",\n "bcrypt-nodejs": "^0.0.3",\n "body-parser": "^1.15.1",\n "compression": "^1.6.2",\n "consolidate": "^0.14.5",\n "cookie-parser": "^1.4.1",\n "cors": "^2.8.4",\n "dotenv": "^2.0.0",\n "express": "^4.13.4",\n "express-validator": "^2.20.4",\n "fcm-node": "^1.2.0",\n "geocoder": "^0.2.3",\n "jimp": "^0.2.28",\n "jsonwebtoken": "^5.7.0",\n "moment": "^2.12.0",\n "moment-timezone": "^0.5.14",\n "mongoose": "^4.4.8",\n "mongoose-unique-validator": "^1.0.6",\n "morgan": "^1.7.0",\n "multer": "^1.3.0",\n "mustache": "^2.3.0",\n "node-cron": "^1.2.1",\n "node-excel-export": "^1.4.4",\n "nodemailer": "^2.3.0",\n "nodemailer-mailgun-transport": "^1.3.5",\n "nodemailer-smtp-transport": "^2.7.4",\n "qr-image": "^3.2.0",\n "randomstring": …Run Code Online (Sandbox Code Playgroud) 在我的打字稿项目中,我能够在文件夹的 index.ts 中重新导出默认导出。
例如:
export { default as BaseError } from "./errorResponse";
Run Code Online (Sandbox Code Playgroud)
但我无法像这样导出 JSON 文件。
export * as configFiles from "./config";
Run Code Online (Sandbox Code Playgroud)
如何捆绑和导出 JSON 文件,以便我可以在 tsconfig 的路径中使用它
{
"compilerOptions": {
"paths": {
"@errorClass": ["src/helpers/errorClasses"],
"@config": ["src/config"],
"@routes": ["src/routes"]
},
}
Run Code Online (Sandbox Code Playgroud) 我已经把我的后端放到了aws上。后端 url 在邮递员中工作正常。
但是当我将后端 url 放入 Angular 服务时,locahost 会附加到它的前面。
我该如何解决这个问题。
后端网址:api.angularapp.site
在我的服务中,我这样称呼:
private url = "api.angularapp.site/api/v1";
public signupFunction(data):Observable<any>{
const params=new HttpParams()
.set('firstName', data.firstName)
.set('lastName', data.lastName)
.set('mobileNumber', data.mobile)
.set('email', data.email)
.set('password', data.password)
.set('gender',data.gender)
.set('profilePic',data.profilePic);
return this.http.post(`${this.url}/users/signup`,params);
}//end of signup function
Run Code Online (Sandbox Code Playgroud)
但是当我运行应用程序并尝试注册时,我收到控制台错误:
http://localhost:4200/api.angularapp.site/api/v1/users/signup 404(未找到)
为什么这个 localhost 将自身附加到后端调用 url。
在 url 之前 ** private url = " http://localhost:3000/api/v1 ";** 在这种情况下,角度可以很好地连接到后端。但现在我不明白它是如何在启动中附加角度 locahost url
请帮忙
node.js ×2
angular ×1
http ×1
javascript ×1
json ×1
mean ×1
mean-stack ×1
node-gyp ×1
typescript ×1
ubuntu ×1
ubuntu-18.04 ×1