Node : Cannot find module common - node.js

I was running a node server w/o any issue and for some purpose had to remove the node_modules dir and re-install the dependencies. Upon doing so and running the server again I get this error :
Error: Cannot find module './common'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (C:\Work\Cinde-Node\node_modules\debug\src\node.js:236:18)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
I installed common separately using npm install common but that didnt solve the problem.
How do I fix this ?

It looks like you have a line like
require('./common');
it should be
require('common')

I was getting the same error when I tried running my express project. The following command helped me to fix the issue.
rm package-lock.json && rm -r node_modules && npm i --save --legacy-peer-deps

Related

Cannot find module , Missing modules #557

After npm install -g #vue/cli#3.0.0-beta.9 ,
I run the command vue create client
I get the following output:
module.js:557
throw err;
^
Error: Cannot find module 'cmd-shim'
at Function.Module._resolveFilename (module.js:555:15)
at Function.Module._load (module.js:482:25)
at Module.require (module.js:604:17)
at require (internal/module.js:11:18)
at Object.<anonymous>
(/Users/atalante/.nvm/versions/node/v9.4.0/lib/node_modules/#vue/cli/lib/util/linkBin.js:10:27)
at Module._compile (module.js:660:30)
at Object.Module._extensions..js (module.js:671:10)
at Module.load (module.js:573:32)
at tryModuleLoad (module.js:513:12)
at Function.Module._load (module.js:505:3)
i tried rm -rf node_modules and npm install
but it doesn't work.
This usually occurs when there is an issue with either your node or npm installations, Try updating node.js and npm to resolve the issue which has worked for me in the past. This might help in updating npm : Update NPM

Cannot find module 'semver' When installing Npm

This is the error i got when try to install npm.
please help me to fix it.
module.js:549
throw err;
^
Error: Cannot find module 'semver'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (C:\Users\maheshig\AppData\Roaming\npm\node_modules\npm\lib\utils\unsupported.js:2:14)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
I followed These steps and it solved my issue
uninstall Node.js
Remove the content of the following folders
C:\Users\AppData\Roaming\npm-cache
C:\Users\AppData\Roaming\npm
C:\Program Files\nodejs
Then again install Node https://nodejs.org/en/
In linux you can use the following
sudo rm -rf /usr/lib/node_modules/
or wherever your global node_modules are
then reinstall npm
this solved the problem with me.

Cannot find module 'internal/util/types'

I am trying to setup existing nodejs project on my window
Npm -v :- 6.0.1
node -v :- v8.11.1
When i run node app.js i am getting following error
include-all attempted to
require(C:\xampp\htdocs\sails\backend\api\services\FileUploadService.js)`,
but an error occurred::
Details:Error: Cannot find module 'internal/util/types'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at evalmachine.:31:26
at Object. (C:\xampp\htdocs\sails\backend\node_modules\s3\node_modules\graceful-fs\fs.js:11:1)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object. (C:\xampp\htdocs\sails\backend\node_modules\s3\node_modules\graceful-fs\graceful-fs.js:3:27)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object. (C:\xampp\htdocs\sails\backend\node_modules\s3\lib\index.js:3:10)
Any idea? what i am missing
I had same issue. After researching it, it looks like there are many ways that people have fix this problem.
What caused the problem for me was that I upgraded node and needed to rebuild my project.
npm rebuild
Fixed it for me.
There is a lengthy discussion here:
nodemon
Reverting to an earlier version, resolved the crash I was getting each time I run npm :
sudo n 6.12.0
Thanks to: https://github.com/remy/nodemon/issues/1124#issuecomment-345181229
In Windows 10 I recently had error message also, running nodejs. This error would occur even if I simply ran something simple like npm --version.
I then noticed the error stack trace showed the following script in the call stack:
C:\Users\\AppData\Roaming\npm\node_modules\npm\node_modules\graceful-fs\fs.js:11:1)
It turns out that an earlier version of npm had installed scripts in the user's profile folder and, for some reason, that never got removed - even though I had performed many uninstalls and reinstalls of the latest nodejs version.
Simply removing the entire npm folder under C:\Users\<myusername>\AppData\Roaming\npm solved the issue.
The latest npm installs these scripts in C:\Program Files\nodejs\node_modules\npm, which is where these should be picked up.

Node.js Cannot find module './internal/streams/stream'

I get an error when I want to use gulp for deployment.
Error: Cannot find module './internal/streams/stream'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/var/www/pomelo/themes/pomelo/assets/js/node_modules/gulp-replace/node_modules/readable-stream/lib/_stream_readable.js:50:14)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
So I use npm install readable-stream, but this is still the error.
Why? How can I fix it?
Try this:
rm -rf node_modules
npm install
What worked for me is to delete the package-lock.json file and the node_modules folder, then run npm install.
It's a core node lib. Try first,
npm cache clean
If not work, reinstall node

How to solve ini error for npm

I just install node.js to my system. My node version is v8.10.0. When I try npm -v I get following error.
module.js:549
throw err;
^
Error: Cannot find module 'ini'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (C:\Users\ai8\AppData\Roaming\npm\node_modules\npm\node_modules\config-chain\index.js:4:11)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
How can I fix this issue?
I had a same kind of issue before. I tried all the solutions even tried uninstalling and reinstalling node js. Finally, I tried by removing the node_modules from the user folder.
Then, run npm install.
This worked for me.
Hope it works for you
delete node_modules and reinstall
rm -rf node_modules
npm install
Use this link for further details. Hope this will help you.
npm

Resources