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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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?
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 :
In your server.js.
app.get('/', function(req, res) {
res.sendFile(path.join(__dirname + '/your_folder_if_exist/index.html'));
});
In your server.js.
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/@myusernam e/myprojec tname
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?
-testdirectory
--node_modules folder
--package-lock.json
---node_modules/@myusernam
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.
ASKER
Thank you
Glad I could help.
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.