Cannot find module 'internal/util/types' - node.js

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.

Related

cannot find module './framer' after deleting node modules

I was cleaning up the angular code and, deleted some unused custom modules. After which, It was throwing an error about a deleted imported component in app.module.ts even though it was already removed from import.
Then, I manually deleted the node modules, ran npm install and tried to run npm start which gives me the following error:
Cannot find module './framer'
Error: Cannot find module './framer'
at Function.Module._resolveFilename
(internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (C:\Users\NBS627\eclipse-workspace\ccmobile-
UI\node_modules\spdy-transport\lib\spdy-transport\protocol\base\index.js:7:18)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (C:\Users\NBS627\eclipse-workspace\ccmobile-
UI\node_modules\spdy-transport\lib\spdy-transport.js:10:27)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
I have no idea about this error. Please help.
Your error says that you have a problem with your spdy-transport module.
To solve this you must update your spdy-transport module:
npm un spdy-transport
Then:
npm i spdy-transport
One of the packages which you deleted might have a dependency on an existing module
for example, when we do npm install package-name, often more than one folder are created in the node_modules folder, we may think that it is not required but it is in fact needed

Node : Cannot find module common

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

ng serve : Cannot find module './templates.js'

I just transfered my Angular 6 project from one computer to another and in the new device I get the following error when trying to ng serve
I have also tried with npm install templates.js , the dependency is installed but this error pops again
Cannot find module './templates.js'
Error: Cannot find module './templates.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:603:15)
at Function.Module._load (internal/modules/cjs/loader.js:529:25)
at Module.require (internal/modules/cjs/loader.js:658:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (C:\Users\Godwin\Desktop\livigro\node_modules\chalk\index.js:6:18)
at Module._compile (internal/modules/cjs/loader.js:722:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:733:10)
at Module.load (internal/modules/cjs/loader.js:620:32)
at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
at Function.Module._load (internal/modules/cjs/loader.js:552:3)
at Module.require (internal/modules/cjs/loader.js:658:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (C:\Users\Godwin\Desktop\livigro\node_modules\postcss\lib\css-syntax-error.js:9:14)
at Module._compile (internal/modules/cjs/loader.js:722:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:733:10)
at Module.load (internal/modules/cjs/loader.js:620:32)
This could be similar to ng serve: Cannot find module 'tapable'
Thanks in Advance :)
Removing the node_modules folder and again using npm install solves the problem , and the ng serve working good
It can occur for two reasons:
1. templates.js is not present.
2. templates.js is present but you provided the wrong relative path.
Kindly check once. And you don't need to install "templates.js" if it's not an external package. Npm install is used for installing the external packages.

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

Cannot find module 'ansi-regex' | npm not getting uninstalled or updated

I am unable to uninstall or update npm. I tried running rn -rf node-modules, rimraf node-modules, and even manually deleting the npm folder from the system. I even removed the environment variable. Unfortunately, nothing is working.
I uninstalled nodejs and completely removed ALL the folders and temp files. Post system restart, I did a fresh installation of nodejs and when I again tried to install npm, I get this error:
throw err;
^
Error: Cannot find module 'ansi-regex'
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> (C:\Users\Admin\AppData\Roaming\npm\node_modules\npm\n
ode_modules\strip-ansi\index.js:2:38)
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)
Basically, whatever method I tried, I get the same error. Please help!
node version: v6.11.0
OS: Windows 8
I have also tried installing 'ansi-regex' using npm install ansi-regex

Resources