Foundation Certificate in Test Automation - Javascript - npm start error

Hi all, I must apologise for my constant questions on here - but I had a feeling, going by experience that it’s the setup and installs that always cause me the most troubles.

My issue is, I have run npm install, things look good. But when I run npm start, I get the following error (I am running this in the same location I installed npm and node):

Jamess-MacBook-Pro:~ Jayla$ npm start
npm ERR! Missing script: "start"
npm ERR! 
npm ERR! Did you mean one of these?
npm ERR!     npm star # Mark your favorite packages
npm ERR!     npm stars # View packages marked as favorites
npm ERR! 
npm ERR! To see a list of scripts, run:
npm ERR!   npm run

npm ERR! A complete log of this run can be found in: /Users/Jayla/.npm/_logs/2024-02-01T09_30_35_606Z-debug-0.log
2 Likes

npm is a package manager, so no idea why ‘start’ would be a valid verb. I’m not a java expert at all, (Yes I’m the only tester here who hates AND has never learned very much java.) But someone who is will be able to help if you can provide us with some context.

4 Likes

npm start looks for a ‘start’ entry in the package.json file in the location from where you run the command.
An example of what to look for:
image

Does the project have such a script configured?

1 Like

Thank you for your responses. I’m not sure, I haven’t yet opened the project as this is one of the steps to do listed before opening the project, as quoted below:

1. First we download the code for our project which can be found at https://github.com/ministryoftesting/mot-cert-support-app-js. You can either clone the repository if you’re comfortable with using GitHub, or alternatively download the ZIP file by clicking on the green code button on the page.
2. Once the code is on your machine, load up Visual Studio Code and open the project you have downloaded.
3. Open up a new Terminal window in Visual Studio Code by selecting Terminal > New Terminal.
4. Within the Terminal run `npm install`.
5. Once the installation process is complete and is successful, run `npm start`.
6. Watch the terminal window that has just opened and wait for the application to load (Once it shows the message webpack compiled successfully). Then open http://localhost:8080 in a browser.

Ok. It seems that you have not run the npm start in the folder of the project.

Regardless of which terminal you use VSCode/cmd/Terminal/git Bash, you need to change the current directory you are in so that you are in the folder mentioned here as ‘mot-cert-support-app-js’:

If you’re not familiar already with MacOSX Terminal, have a look at least at the files/folder navigation. Example:

3 Likes

Thank you @ipstefan for your response

I navigated to the folder in which I cloned the project to, then made sure I was in the folder you mentioned, and then when I try npm start I see this:

Jamess-MacBook-Pro:test-automation Jayla$ ls
mot-cert-support-app-js package-lock.json
Jamess-MacBook-Pro:test-automation Jayla$ cd mot-cert-support-app-js
Jamess-MacBook-Pro:mot-cert-support-app-js Jayla$ npm start

> timesheet-manager@0.1.0 start
> concurrently --kill-others "cd mocks && java -jar wiremock-standalone.jar --port 8080" "react-scripts start"

sh: concurrently: command not found
1 Like

Ok. Then you have probably not run in the same folder the command:

npm install

The npm install will look in package.json for ‘dependencies’ and install those:
image

Once you run it you should see several libraries imported/installed.
Then you can continue with:

npm start

2 Likes

Thanks again! Shall I be concerned with the vulnerabilities listed? They do not seem to get resolved no matter how many times I run the audit fix commands below:

131 vulnerabilities (1 low, 104 moderate, 22 high, 4 critical)

To address issues that do not require attention, run:
  npm audit fix

To address all issues (including breaking changes), run:
  npm audit fix --force
1 Like

Vulnerabilities like those regularly appear in many production projects.
They are usually ignored. But if you care about the security of a live product, you might check what’s about critical ones. Sometimes they are considered for the potential incompatibilities, although other ways would trigger those errors like starting or building a project.

Libraries that you might use via package.json are dependent on libraries that are dependent on other libraries, and so on. Hundreds of packages need to be up to date, compatible with each other, not deprecated, secure, and so on.

What can help to keep up to date with the latest versions is to check the latest versions available for the libraries you use. You can do:

npm outdated

Then based on the returned list of the libraries, you can choose to change to a major, or minor version of the same library.
You can do that by editing the package.json and changing the version assigned to a library. Save the file changes.
Then do again an install to retrieve those latest libraries:

npm install

2 Likes

Thank you so much, all of your help has been really useful and I’m super grateful

2 Likes