Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm run sever is not working #45

Open
abdullah-doleh opened this issue Apr 15, 2022 · 3 comments
Open

npm run sever is not working #45

abdullah-doleh opened this issue Apr 15, 2022 · 3 comments

Comments

@abdullah-doleh
Copy link

C:\Users\home\3-services\3-services>npm run server

angular-course@0.0.0 server
./node_modules/.bin/ts-node -P ./server.tsconfig.json ./server.ts

'.' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\home\3-services\3-services>

@MahdiSaber
Copy link

This repository seems to be outdated. I had the same problem.
In order to fix the issue, try this command:
.\node_modules\.bin\ts-node -P .\server.tsconfig.json .\server.ts

The content of server.ts is as follows:

import * as express from 'express';
import {Application} from 'express';
import {getAllCourses} from './server/get-courses.route';
import {saveCourse} from './server/save-course.route';


const bodyParser = require('body-parser');

const app: Application = express();

app.use(bodyParser.json());

app.route('/api/courses').get(getAllCourses);

app.route('/api/courses/:id').put(saveCourse);



const httpServer = app.listen(9000, () => {
    console.log('HTTP REST API Server running at http://localhost:' + httpServer.address().port);
});

@sandeepsauravdas
Copy link

image_2022-09-19_205009436
For me, the Express server runs however when checking on the link i.e. localhost:9000 all I get is the above error message
Cannot GET /

Below is the output from npm run server:

> angular-course@0.0.0 server C:\FisherSS\angular-course
> ts-node -P ./server.tsconfig.json ./server.ts

HTTP REST API Server running at http://localhost:9000

@rgbk21
Copy link

rgbk21 commented Nov 6, 2022

When I google, this is the link that comes up. Doing this fixe the issue in my case. Replace the "server" in package.json with this:

"server": "node ./node_modules/ts-node/dist/bin.js -P ./server.tsconfig.json ./server.ts"

What we are doing is side-stepping usage of the bash file and directly pointing to the binary as mentioned here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants