angular-course icon indicating copy to clipboard operation
angular-course copied to clipboard

npm run sever is not working

Open abdullah-doleh opened this issue 2 years ago • 3 comments

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

[email protected] 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>

abdullah-doleh avatar Apr 15 '22 08:04 abdullah-doleh

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);
});

MahdiSaber avatar May 10 '22 08:05 MahdiSaber

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:

> [email protected] server C:\FisherSS\angular-course
> ts-node -P ./server.tsconfig.json ./server.ts

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

sandeepsauravdas avatar Sep 19 '22 15:09 sandeepsauravdas

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.

rgbk21 avatar Nov 06 '22 00:11 rgbk21