Getting started with NPM...
I can run the following command to start my app.
node app
But when I run the following command, I get
I know its too late to answer, but in case any wanderer like me faces the same problem in future..
need to add node
keyword ahead of app.js
in script. So, start script should
"scripts": {
"start": "node app.js"
},
That solved for me.
If you're using Visual Studio Code, it may have taken over running the script. If in VS Code, hit F5 and see if the project runs properly. I don't know why it does this, but did for me. This tipped me off
Use >node app.js instead of >app.js
Then it will work
I had this problem as well. The .js files are associated with the Microsoft Script Engine. Some suggested that we dis-associate the extension with the program, but I do not think that is necessary. I was able to fix the issue with the following instruction that I found in the NODE Docs.
Please make sure that your file(s) referenced in bin starts with
#!/usr/bin/env node
otherwise the scripts are started without the node executable!
When I faced the same problem using Visual Studio Code, I was trying to run localhost at port 8080, however by pressing F5 I was able to know that the port was already taken and so I changed the port to 3000, and viola! that worked for me.
Check out the error