Trying to install js packages on a glitch website, get server.js unable to be found error

im trying to install aos for my html website using package.json, but i cant install anything because i get an error saying module server.js cannot be found, because obviously i dont have a file named that. what do i do? heres my json file:

{
  "main": "script.js",
  "scripts": {
    "start": "server.js"
  },
  "dependencies": {
    "aos": "2.3.4"
  },
  "engines": {
    "node": "14.x"
  }
}

Hi @lettucedealer, welcome!

I guess you could change the start property to point to a file that does exist, or else create an empty server.js file, just to get you past the error so you can install packages?

Let us know :slight_smile:

A few things seem “odd” but I hadn’t heard of AOS until you posted this. It is a client-side JS library isn’t it? If you don’t have a server you should be able to load it directly into the page much as you would jQuery for instance.

Also “server.js” isn’t a start command. “node server.js” would be if you want node to run it. And you have script.js set as “main”. Where did the setting values come from?

hey, so i added an empty server.js file, and while i get no errors and a message saying the total install time which im guessing means it worked, my app status and logs loads forever and when i try to access my website it starts forever

ill be honest, adding the script.js as main was cause I basically have no idea what I’m doing and just grasping at straws at this point. Not sure what you mean by I could just “load it directly to the page” tho. Like just directly add the scripts to the directory?

Hard to say. Generally one has either a “static website” or a “dynamic website”. A simple static website is a collection of webpages. They can contain JavaScript but that runs on the client (browser). So libraries such as jQuery (and/or whatever) are loaded into the page along with the HTML. On a dynamic website you have server software (there are a number of them) that “serves” pages and listens for (and responds to) events from the webpages.

Re: AOS, are you following a tutorial of any kind?

nope. Basically I was looking for a way to run an html element’s animation only when the element is visible on screen, and so I asked for a method on a discord server and AOS was suggested to me. I’m actually pretty knowledgeable in desktop applications, like I have a github page and whatever, but anything that involves servers is very new to me. So if the thing is client side, is there a way for me to just install it using npm or something?

alright i tried using npm to install it, but i now have an error saying /usr/bin/env node: no such file or directory

I believe that is where you are going wrong. Again AOS is client-based (as far as I know) not “server based” which appears to be what you are trying to do.

You can include lots of libraries directly in a webpage that is very, very commonplace an example exist all over the place. jQuery is such a library, Greensock for animation, video players, fonts, etc., etc.

This guys does very good instructional videos I haven’t watched this but I would bet you learn something by following it.

OHHH, I get it. If only I checked the github page instead of the npm page lol. So yeah all I had to do was just link the css and scripts directly into the directory. Thanks for the help man