Erika
Erika

Reputation: 16

npm run server error '.' is not recognized as an internal or external command,

I ran into this problem with angular and npm and I'm yet to find a solution for it . The project I'm working is this angular project from github , this exact code worked for others so the issue is probably from my side .

the command npm run server gives the following error:

[email protected] server ./server.ts

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

The server script in package.json file:

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

I ran the npm install command first and all the files and dependencies are succefully installed so I'm not sure what's the problem .

Upvotes: 0

Views: 651

Answers (3)

vikas sharma viky
vikas sharma viky

Reputation: 37

Actually the problem is with "/" in the command on windows. Replace it with "" and it will work like as follows

.\node_modules\.bin\ts-node -P .\server.tsconfig.json .\server.ts

Upvotes: 0

Mahdi Saber
Mahdi Saber

Reputation: 41

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

Upvotes: 1

Hassan Gad
Hassan Gad

Reputation: 19

I think the problem with the / itself so replace it to something like that .\\node_modules\\.bin\\ts-node -P ./server.tsconfig.json ./server.ts

Upvotes: 0

Related Questions