Link to home
Start Free TrialLog in
Avatar of VBBRett
VBBRett

asked on

How do you launch your index.html into browser window?

How do you make your npm package which includes an index.html page and a few folders of css and and javascript files launch a web page after you type "npm start" in the console window?
Avatar of Rikin Shah
Rikin Shah
Flag of India image

Hi,

I believe you just need to go to your browser and type http://localhost:<port>/
Port will be the port number that you have mentioned in config file.
ASKER CERTIFIED SOLUTION
Avatar of Zakaria Acharki
Zakaria Acharki
Flag of Morocco image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of VBBRett
VBBRett

ASKER

So in order to do npm start and launch into a window you have to have index.js in your project folder or server.js in your project folder?  I'm confused
You will need "server.js" for sure if you want to start your own server. could you show us your current structure please?
Avatar of VBBRett

ASKER

and I place server.js into the directory of index.html?
It should be just with "package.json" in the same directory, then you could put the "index.html" where you want up to your project structure.
Just a note I consider that you're already :

app.get('/', function(req, res) {
    res.sendFile(path.join(__dirname + '/your_folder_if_exist/index.html'));
});

Open in new window


In your server.js.
Avatar of VBBRett

ASKER

So when I published my package, for some reason, it threw my profile name with my package information into the node_modules so here is what happens when it is installed...

-testdirectory
--node_modules folder
--package-lock.json
---node_modules/@myusername/myprojectname

this is completely the wrong project structure.  What I need is the following:

I need the following in the same folder
myprojectname folder
node_modules folder

but for some reason, the project folder gets pushed into node_modules.  What can i do to correct this?
This problem must be posted as a new question so we keep the things arranged and if you do you will get help from many experts as quickly as possible.
Avatar of VBBRett

ASKER

Thank you
Glad I could help.