How to set local web server in Visual Studio Code

丶灬走出姿态 提交于 2021-02-18 05:10:56

问题


I am new in VS code and working in typescript.Just I am trying to set local server path to open my HTML file.how to set that and when I was trying to set always I am getting error. I can not use this (NPM install) and (NPM start) command in terminal.If I use this command I am getting error. Any proxy issue? How to resolve this issue in VS code?

Folder structure:

TsDemo--folder name

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

app.ts
index.html 
tsconfig.json

i follwed this link:https://blogs.msdn.microsoft.com/cdndevs/2016/01/24/visual-studio-code-and-local-web-server/ but not working. If I use this command: 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

If I use this command: D:\TsDemo>NPM start

        D:\TsDemo>npm start
        >TSDEMO@1.0.0 start D:\TsDemo
        > npm run lite

        npm WARN invalid config loglevel="notice"

        > TSDEMO@1.0.0 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! TSDEMO@1.0.0 lite: `lite-server --port 10001`
        npm ERR! Exit status 1
        npm ERR!
        npm ERR! Failed at the TSDEMO@1.0.0 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! TSDEMO@1.0.0 start: `npm run lite`
        npm ERR! Exit status 1
        npm ERR!
        npm ERR! Failed at the TSDEMO@1.0.0 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    

回答1:


Just use the Live Server Extension. Install it from VS Code directly and you will be fine. You'll then have a link in the bottom of your editor to start and run the server automatically and also view your HTML immediately.

Also check: live-server-web-extension and Live Server



来源:https://stackoverflow.com/questions/47908158/how-to-set-local-web-server-in-visual-studio-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!