Nodejs module not found - node.js

I'm trying to install socket.io on localhost.
I installed nodejs like this:
1. npm install pm2 -g
2. npm install socket.io
3. pm2 start C:\xampp\htdocs\server\app.js
Yesterday It was successful and I worked on my project.
But today when I start same file again, I get an error like this;
https://i.imgur.com/V89qWhP.png
And I open logs, the message showed:
https://i.imgur.com/pLj5dgx.png
I'm trying to solve this problem for hours.
I even tried to reinstall Node at least 4-5 times.
Still same problem, please help.

At first glance I would recommend you to run a npm install before starting your app.
We need additional information about your require statement, your package.json dependencies and the full error message.

Related

I cannot start my nestjs project after a reboot

I don't know what happened prior to this issue but after each reboot i have to fully remove npm and nodejs, reinstall both npm and nodejs in order to start my nestjs project.
After rebooting running the npm run start command in my nestjs project, npm stops halfway and exits without any error codes (Link below of the terminal output).
https://i.stack.imgur.com/zrbXp.png
What could it be? Is there perhaps some system path that gets wiped on reboot?
Any help or pointers would be greatly appreciated
Turns out both my angular project and my nestjs project required me to run a very specific version of node. anything else resulted in a silently crashing nestjs application with no errors.
For anyone stumbling into the same problem try fiddling around with the node version you're running
npm install -g n
n 10

Getting started with Create React App - "Cannot find module"

I'm using the "Getting Started" guide because I've been experiencing endless errors trying to create a react app so far when following tutorials.
And straight away I'm running into a problem. When I run npx create-react-app my-app I get the following:
Cannot find module 'C:\Users\Aristophanes\node_modules\create-react-app\index.js'
Can anyone advise me what I'm doing wrong? Thanks.
This must be a problem related with your node installation (maybe you removed manually create-react-app package?). I'd recommend following these steps:
Uninstall node and npm
Delete the npm cache and npm modules in your machine (In Windows machine you can usually find them at C:\Users\ {username} \AppData\Roaming\npm-cache and C:\Users\ {user name} \AppData\Roaming\npm) respectively.
Install node and npm again
If you really don't want to delete node and npm, try step 2 and see if that works. Following these steps did the job for me, hope that helps you.
I think you might miss installing Node and npm in your machine.
I had same issue a few times. Every time I was searching thru net for a solution, and for every time i just typed in terminal
npm i node
and its just started working

Starting node server gives node fibers error

I was working on node. Everything was fine. I reinstalled my windows and now when I start node server, it gives me the following error.
I reinstalled fibers as well but still the same issue. Any guesses what I should do?
Thats sounds to me for reinstalling node.js completely, see e.g. this post.
The hard thing is to install the globale modules (those which you have installed with npm -g before you've started the project). From your project make a copy without the node_modules and enter npm install. This worked for me, but I have to deal with the error messages which are missing the global modules.

PM2 or any npm module Stuck at the start of installation

I am trying to install PM2 for node.js, But whenever i am installing it gets stuck at the very start,I tried googling it but cant find anything related to my problem,I am on Windows 10,I cannot install any module!
I reinstalled my windows and thats it,No one was able to help except telling me to update npm which i did but didnt work.

nodejs express npm install dependencies errors

I am very new to node.js and am following this tutorial
When I get to step 5, after completing step 1-4 successfully, and run the npm install command I get these errors.
http://i.stack.imgur.com/LPN49.png
Also when I run npm start command I get these errors in image 2
http://i.stack.imgur.com/TrOJz.png
Please help me rectify these errors.
I originally answered this question on Quora -- including an explanation about why the SO community frowns on this type of question -- but here's the technical portion if anyone comes to this question for a more general answer:
npm install goes through the list of dependencies in your package.json file, fetches each one from NPM, then installs it locally for you. If there was an error with that process then you will be missing one or more dependencies -- if you try to run node /path/to/node/server/file then Node and Express will start looking for dependencies that may not be there because your npm install errored out.
Additionally, you can only use npm start if the package.json file has a scripts property that tells node what start script to use. If it's not there, it falls back to node server.js, which won't start your server if it's called something other than server.js. (For more information: node.js express npm start)
You should try to confirm whether your package.json is actually at the file path on the first "ERR!" line after you ran npm install. I'm guessing it didn't find the file so it couldn't install dependencies, and then you're getting an error from npm start because you didn't install Express's body-parser dependency, which prevented it from starting your server.

Resources