काम नहीं कर रहा है मैंने टाइपस्क्रिप्ट का उपयोग करके एक पुनरारंभ परियोजना सेट अप करने का प्रयास किया। विभिन्न कोशिश करता बाद मैं का उपयोग करके एक काम संस्करण बनाने के लिए कर रहा था "मॉड्यूल: commonjs" tsconfig.json मेंमॉड्यूल = सिस्टम का उपयोग करके नोड के लिए टाइपस्क्रिप्ट सेट करना
मैं पसंद करते हैं इस प्रणाली का उपयोग करने के लिए - लेकिन मैं इसे सेट अप करने के लिए systemjs
साथ में सक्षम नहीं थाboot.ts
import {AppServer} from './app';
var _appServer = new AppServer();
tsconfig.json
{
"compilerOptions": {
"target": "ES5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
},
"exclude": [
"node_modules"
]
}
app.ts
/// <reference path="typings/restify/restify.d.ts" />
import {Server, Response, Request, createServer} from 'restify';
export class AppServer {
private server: Server;
constructor() {
this.init();
}
init() {
this.server = createServer();
this.server.get('/hello/:name', this.respond);
this.server.listen(8080,() => {
console.log('%s listening at %s', this.server.name, this.server.url);
});
}
respond(req: Request, res: Response, next: Function) {
res.send('hello ' + req.params.name);
next();
}
}
tsconfig.json में "module": "system"
का उपयोग कर, मैं (boot.ts में भी import System = require('systemjs')
के साथ) निम्नलिखित आउटपुट प्राप्त:
➜ server git:(master) ✗ npm run server
> [email protected] server /Users/maquh/Development/02_Backgular/server
> node boot.js
/Users/maquh/Development/02_Backgular/server/boot.js:1
(function (exports, require, module, __filename, __dirname) { System.register(['./app'], function(exports_1) {
^
ReferenceError: System is not defined
at Object.<anonymous> (/Users/maquh/Development/02_Backgular/server/boot.js:1:63)
at Module._compile (module.js:425:26)
at Object.Module._extensions..js (module.js:432:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at Function.Module.runMain (module.js:457:10)
at startup (node.js:138:18)
at node.js:974:3
Transpiled बूट .js
System.register(['./app'], function(exports_1) {
var app_1;
var _appServer;
return {
setters:[
function (app_1_1) {
app_1 = app_1_1;
}],
execute: function() {
//System.import('./app.ts').
_appServer = new app_1.AppServer();
}
}
});
//# sourceMappingURL=boot.js.map
अद्यतन:
[Error: ENOENT: no such file or directory, open '/Users/markusbellgardt/Development/02_Backgular/server/restify']
समस्या क्या है? आप कैसे जानते हैं कि आप सक्षम नहीं थे? – Pablo
जोड़ा गया टर्मिनल आउटपुट – Maquh
आप 'boot.ts' दिखा रहे हैं, जिसमें ऐसा लगता है कि' boot.js' से क्रैश होने वाली रेखा दिखाई नहीं दे रही है। क्या आप 'boot.js' की डिस्क सामग्री (संकलित आउटपुट) दिखा सकते हैं? – Claies