Hi there i am trying to play around with packages and installed the date-fns package but cant seem to use it, i have a feeling its because of how my folders are set up but dont know the right way, where should my node modules folder and json package folders be in relation to my folder with all the projects im working on be? my projects are in a folder called projects on my desktop
enter image description here
Question posted in Javascript
A very good W3school tutorial can be found here.
A very good W3school tutorial can be found here.
2
Answers
Adam.
You need to set the structure of your project as below.
enter image description here
Hope this can help you.
Thanks.
The basic steps to install a package in a project that uses npm, if you’re starting from scratch, is to prepare the environment first before using the package. Here’s what I do:
node
andnpm
installed in your local terminal.npm init
to initiate thepackage.json
vite
. Runnpm install -D vite
date-fns
. Runnpm install date-fns
main.js
script. (We’ll create the script after this step)main.js
, then use thedate-fns
there to print the date into the HTML.package.json
to run thevite
:npm run dev
in your terminal. If everything is fine, it shall create a webserver and you can run it in your browser.