How to run npm serve with https? - npm

I just had a index.html in my working directory, and typed npx serve.
I can access http://localhost:3000 but I want to host https://localhost:3000.
How to run 'serve' with https mode?
What option do I need?

Related

empty site after using nmp run build (vue 2 cli)

Im using project vue 2 cli + vuex + router (without history mode) but when Im opening index.html, after "nmp run build" command, site is empty. How can I solve it... I need site to be opened on index.html (like common cdn project)
The dist directory is meant to be served by an HTTP server (unless you've configured publicPath to be a relative value), so it will not work if you open dist/index.html directly over file:// protocol.
Source
One way to test your build, is to install Serve:
// install Serve globally
npm install -g serve
// Run in project root, with folder name as input
serve -s dist

Cannot login into Verdaccio

I have just installed Verdaccio on my computer. I have changed nothing in the config file, apart from adding proxy_related info:
http_proxy: http://proxy.ip:8080
https_proxy: https://proxy.ip:8080
no_proxy: localhost,127.0.0.1
After starting the process, I have tried to login to the registry from the library project workspace
npm adduser --registry http://localhost:4873
But I get this error:
npm ERR! 503 Service Unavailable - POST http://localhost:4873/-/v1/login
If I try to reach http://localhost:4873/ from my browser, I can see the Verdaccio webpage.
What am I doing wrong?
I don't know what kind of environment you are trying this (work, home, etc.) but, for me, my problem was that behind a corporate firewall I have to configure the NPM proxy (http and https), so adding the localhost as an exception to noproxy config attribute of NPM, it worked for me.
npm config set noproxy localhost
Try to change yours, from no_proxy to noproxy, maybe it is simple as that.

vue-cli · Failed to download repo vuejs-templates/webpack-simple: tunneling socket could not be established, statusCode=403

I just started with Vue today and got stuck.
Following is the summary:
npm install -g vue-cli [Result - Successful]
vue init webpack-simple C:\vue [Result - Unsuccessful]
vue init webpack-simple ./ [Result - Unsuccessful]
Throws following error:
vue-cli · Failed to download repo vuejs-templates/webpack-simple: tunneling socket could
not be established, statusCode=403
Then tried the following commands:
npm config set http-profix null
vue init webpack-simple ./
It still throws the error.
Any pointers to this. I am running the script behind proxy wall.
Thanks.
The issue, I suspect is that you're installing from behind a VPN.
You can try disabling it to do the install
on corporate networks that's not always the option
If you don't have the option to disable...
you may be able to use
npm config set registry=http://registry.npmjs.org/
The reason that works is that you're no longer connecting to the default which uses https, where the SSL is failing due the the proxy.
Note that there is an issue of security if you opt to use http instead of https
You may also be able to use a proxy definition in a .npmrc file
If you have your proxy information, you can add it to the .npmrc file in the directory.
https://docs.npmjs.com/misc/config#https-proxy
proxy http://{proxy_server}:{proxy_port}
https-proxy http://{proxy_server}:{proxy_port}
strict-ssl=false
src gist

NPM fallback dependency URL

I have a npm dependency in my project which is pointing to a private git repo. Unfortunately the git repo link does not work in my local but it works fine when we do a jenkins build since that git repo link only allows certain whitelisted ip's (i.e. jenkins ip address).
I have looked into apache proxypass and verdaccio but I am not sure if that is the right approach for this
dependencies": {
"api-module": "git+https://example/repo-name.git",
},
Locally, I want https://example/repo-name.git to route to https://differentUrl/repo-name.git when I do npm install but don't want to update package.json
I had to setup a host entry and provide an alias to that

Cannot run an app from vue-cli on localhost

I installed the Vue-CLI in version 3.7. Run vue create my-project and npm run serve. Everything was fine and got message
App running at:
- Local: http://localhost:8080/
Though on the http://localhost:8080/ I got This site can’t be reached.
I managed to use vue init webpack-simple my-project and then in ./node_modules/webpack-dev-server/bin/webpack-dev-server.js change port number and with the new one it's working but this "trick" doesn't work for vue create anyway.
Node version 11.11 and OSX Mojave. There should not be anything that could block the port. I have no idea what to do with this.
please run this command in your vue project directory:-
npm run serve
OR
yarn serve
After run command refresh your browser. this command would be run repeatedly when you get 'This site can’t be reached'.
Do this:
Remove your Node.js and again install latest version here
On the installation path choose npm package manager and install
Open cmd and enter this:
npm install -g #vue/cli
After install vue cli (Previous step) enter to cmd this:
vue create name-app
After some minutes (It depends on how fast your internet is) be sure You have the correct installation
So enter in cmd this:
npm run serve
Then you should be able to navigate to localhost page http://localhost:8080
You can override webpack dev host like this:
vue.config.js
module.exports = {
devServer: {
host: '127.0.0.1',
port: 8080,
public: 'localhost:8080',
},
};
Terminal output
App running at:
Local: http://127.0.0.1:8080/
Network: http://localhost:8080/
The answer is from shenron.