Mean Stack Tutorial - 7 - Connecting with Express server

preview_player
Показать описание

📱 Follow Codevolution

Рекомендации по теме
Комментарии
Автор

For those with dirname is not defined error, you must make sure that there is 2 underscore infront of dirname. So instead of _dirname, it is __dirname

zimboprofighter
Автор

very clean and easy to understand....good job man pls keep it up

himanshutank
Автор

Hi i am unable to connect to appComponent while running the localhost:3000 i am getting following error "Uncaught SyntaxError: Unexpected token <" in runtime.js, pollyfills.js, styles.js, vendor.js, main.js in console donno what wrong i have done .i am using Angular7






<!Doctype html>
* -> Uncaught SyntaxError: Unexpected token <
<html lang="en">
<head>
<meta charset="utf-8">
<title>MeanApp</title>
<base href="/">

<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<app-root></app-root>
<script type="text/javascript" type="text/javascript" type="text/javascript" type="text/javascript" type="text/javascript"
</html>

ashwini
Автор

Getting error as
Thorw err;
And err is cannot find module '.server/routes/api'
Require stack.
But I have created the folder server/routes/api but still getting error

sampadabathe
Автор

Could you please say how to combine express and ui. Means when I am running ng serve or node server, only one thing getting .

pradeepkumarsoni
Автор

First of all thanks for the tutorial. Here I'm facing an issue. can you please take a glance and suggest me the way out. My Angular version is 6.0.3. I got those error in the console IN localhost:3000. But when I hit localhost:3000/api it works fine and gives "api works"

runtime.js:1 Uncaught SyntaxError: Unexpected token <
polyfills.js:1 Uncaught SyntaxError: Unexpected token <
styles.js:1 Uncaught SyntaxError: Unexpected token <
vendor.js:1 Uncaught SyntaxError: Unexpected token <
main.js:1 Uncaught SyntaxError: Unexpected token <

Can you please help.

deepkarmakar
Автор

localhost:3000/api - still shows the default page. Copy-pasted code from your github - the same result. Console: Error: Cannot match any routes. URL Segment: 'api'

RinatYouldashbaev
Автор

when i tried localhost:3000
no such file or directory, stat

mdjasim
Автор

I am getting this error, could some one please resolve this error ??
i have followed all the steps of creating server but it showing errors
module.js:549
throw err;
^

Error: Cannot find module
at (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Function.Module.runMain (module.js:693:10)
at startup (bootstrap_node.js:191:16)
at bootstrap_node.js:612:3

offroadingutv
Автор

sir my node server command is throwing an error..what could be an error here if the code is copy paste of urs
it throwing an error..module.js:471
throw err;
^

Error: Cannot find module
at (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:393:7)
at startup (bootstrap_node.js:150:9)
at bootstrap_node.js:508:3

tanubkn
Автор

i have a probleme when i go to my localhost i have "Cannot GET /".

warlokgames
Автор

Localhost doesn't shows app works
But if I type localhost:3000/api then it works

KAVITAJAGTAP
Автор

const api = add in server.js file now will get "api works"

reddysurekha
Автор

Really great and straightforward tutorial, thanks for sharing !

PiniCheyni
Автор

Sir of typing localhost:3000 on web browsers URL it shows error message index.html not found.

ankitpatra
Автор

i have followed all the steps of creating server but it showing errors
module.js:540
throw err;

ratankarande
Автор

It's not clear why to serve static folder

simpleway
Автор

sir it throwing error like this __ dirname not defined

sainathballa
Автор

Specifying other routes you have error to render the index.html page in the dist folder.
Code should be like this:
app.get('*', function(req, res) {
res.sendFile(path.join(__dirname, 'dist/index.html'));
});

sagartimalsina