To fix npm install gives error "can’t find a package.json file" with JavaScript, we run npm install with the package name.
For instance, we run
npm install express
to install the express package.
Then a package.json file is created automatically with a list of installed packages.