Ho creato un progetto Node JS in Visual Studio (comunità professionale e 2013 2012) con NTVS e usato un generatore Yeoman per creare un Knockout SPA app (usando l'opzione dattiloscritto nella configurazione del generatore).Come posso eseguire il debug di un generatore Yeoman KO (con dattiloscritto e gulp) Nodo Progetto JS in Visual Studio con Node JS Tools per studio visivo
Ora ho bisogno di decidere quale file impostare come file di avvio durante il debug (premendo F5). Suppongo che questo sarebbe ./src/app/require.config.js perché altrimenti ottengo un errore che richiede è indefinito.
All'avvio del debug, tutto sembra a posto e viene visualizzata una finestra della console con il messaggio "Debugger sta ascoltando la porta 5858". Ma quando avvio localhost: 5858, non c'è server/sito web.
Posso avviare l'app su un server su un'altra porta, ma in questo caso non vengono colpiti punti di interruzione, nemmeno nel file di avvio.
Quindi le mie domande sono: - cosa devo impostare come file di avvio? - Come si esegue il debug della mia app in Visual Studio con NTVS?
Modifica
ho stabilito che quando aggiungo un nuovo NTVS progetto vuoto viene creato un file con server.js:
var http = require('http');
var port = process.env.port || 1337;
http.createServer(function (req, res) {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Hello World\n');
}).listen(port);
L'impostazione di questa come i risultati in file di avvio debugging funzionante per questo file.
Come posso caricare ancora require tramite require.config.js e avviare la mia app con startup.ts?
require.config.js
// require.js looks for the following global when initializing
var require = {
baseUrl: ".",
paths: {
"bootstrap": "bower_modules/components-bootstrap/js/bootstrap.min",
"crossroads": "bower_modules/crossroads/dist/crossroads.min",
"hasher": "bower_modules/hasher/dist/js/hasher.min",
"jquery": "bower_modules/jquery/dist/jquery",
"knockout": "bower_modules/knockout/dist/knockout",
"knockout-projections": "bower_modules/knockout-projections/dist/knockout-projections",
"signals": "bower_modules/js-signals/dist/signals.min",
"text": "bower_modules/requirejs-text/text"
},
shim: {
"bootstrap": { deps: ["jquery"] }
}
};
startup.ts
import $ = require("jquery");
import ko = require("knockout");
import bootstrap = require("bootstrap");
import router = require("./router");
// Components can be packaged as AMD modules, such as the following:
ko.components.register('nav-bar', { require: 'components/nav-bar/nav-bar' });
ko.components.register('home-page', { require: 'components/home-page/home' });
// ... or for template-only components, you can just point to a .html file directly:
ko.components.register('about-page', {
template: { require: 'text!components/about-page/about.html' }
});
ko.components.register('grid-page', { require: 'components/grid-page/grid-page' });
// [Scaffolded component registrations will be inserted here. To retain this feature, don't remove this comment.]
// Start the application
ko.applyBindings({ route: router.currentRoute });
Modifica 2
Con ulteriori indagini posso iniziare la mia app con un server.js file come file di avvio contenente
var http = require('http');
var app = require('./src/app/startup.js');
var port = process.env.port || 1337;
http.createServer(app).listen(port);
ma questo comporta l'errore "definizione non definita".
Abbiamo provato il pacchetto amdefine e questo ha risolto l'errore 'define is undefined', ma ci ha dato l'errore 'jquery is undefined' dato che il file requirejs.config.js contiene quei percorsi e possiamo ' t sembrano caricare quelli –
scusa, l'errore ricevuto è 'impossibile trovare il modulo' jquery '' –
Vedo, ma quello che non capisco è il link che hai fornito. Che cosa ha a che fare con la nostra situazione (a parte la parte NodeJS) –