web-dev-qa-db-fra.com

Comment définir le serveur Web local dans Visual Studio Code

Je suis nouveau dans le code VS et travaille dans TypeScript.Juste j'essaie de définir le chemin du serveur local pour ouvrir mon fichier HTML.Comment le définir et quand j'essayais de le définir toujours, je reçois une erreur. Je ne peux pas utiliser cette commande (NPM install) et (NPM start) dans le terminal. Si j'utilise cette commande, j'obtiens une erreur. Un problème de proxy? Comment résoudre ce problème dans le code VS?

Structure des dossiers:

TsDemo--folder name

.vscode
   ->launch.json
   ->tasks.json
out
    ->app.js
    ->app.js.map

app.ts
index.html 
tsconfig.json

j'ai suivi ce lien: https://blogs.msdn.Microsoft.com/cdndevs/2016/01/24/visual-studio-code-and-local-web-server/ mais ne fonctionne pas. Si j'utilise cette commande: D:\TsDemo> NPM install

        D:\TsDemo>npm install
        npm ERR! code ETIMEDOUT
        npm ERR! errno ETIMEDOUT
        npm ERR! network request to https://registry.npmjs.org/lite-server failed, reason: connect ETIMEDOUT 10.232.192.45:8080
        npm ERR! network This is a problem related to network connectivity.
        npm ERR! network In most cases you are behind a proxy or have bad network settings.
        npm ERR! network
        npm ERR! network If you are behind a proxy, please make sure that the
        npm ERR! network 'proxy' config is set properly.  See: 'npm help config'

        npm ERR! A complete log of this run can be found in:
        npm ERR!     C:\Users\AppData\Roaming\npm-cache\_logs\2017-12-20T14_16_49_680Z-debug.log

Si j'utilise cette commande: D:\TsDemo> NPM start

        D:\TsDemo>npm start
        >[email protected] start D:\TsDemo
        > npm run lite

        npm WARN invalid config loglevel="notice"

        > [email protected] lite D:\TsDemo

        >lite-server --port 10001

        'lite-server' is not recognized as an internal or external command,
        operable program or batch file.
        npm ERR! code ELIFECYCLE
        npm ERR! errno 1
        npm ERR! [email protected] lite: `lite-server --port 10001`
        npm ERR! Exit status 1
        npm ERR!
        npm ERR! Failed at the [email protected] lite script.
        npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
        npm WARN Local package.json exists, but node_modules missing, did you mean to install?


        npm ERR! A complete log of this run can be found in:
        npm ERR!     C:\Users\411732\AppData\Roaming\npm-cache\_logs\2017-12-20T14_07_41_636Z-debug.log
        npm ERR! code ELIFECYCLE
        npm ERR! errno 1
        npm ERR! [email protected] start: `npm run lite`
        npm ERR! Exit status 1
        npm ERR!
        npm ERR! Failed at the [email protected] start script.
        npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
        npm WARN Local package.json exists, but node_modules missing, did you mean to install?

        npm ERR! A complete log of this run can be found in:
        npm ERR!     C:\Users\AppData\Roaming\npm-cache\_logs\2017-12-20T14_07_41_694Z-debug.log    
8
saranchel n

Utilisez simplement l'extension Live Server. Installez-le directement depuis VS Code et tout ira bien. Vous aurez alors un lien en bas de votre éditeur pour démarrer et exécuter le serveur automatiquement et également afficher votre HTML immédiatement.

Vérifiez également: live-server-web-extension et Live Server

17
k.vincent