Any npm command returns error "Cannot find module yallist" even npm -v - npm

(node:2564) UnhandledPromiseRejectionWarning: Error: Cannot find module 'yallist'
Require stack:
- C:\Users\23354\AppData\Roaming\npm\node_modules\npm\node_modules\lru-cache\index.js
- C:\Users\23354\AppData\Roaming\npm\node_modules\npm\node_modules\semver\classes\range.js
- C:\Users\23354\AppData\Roaming\npm\node_modules\npm\node_modules\semver\classes\comparator.js
- C:\Users\23354\AppData\Roaming\npm\node_modules\npm\node_modules\semver\index.js
- C:\Users\23354\AppData\Roaming\npm\node_modules\npm\lib\utils\unsupported.js
- C:\Users\23354\AppData\Roaming\npm\node_modules\npm\lib\cli.js
- C:\Users\23354\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
at Function.Module._load (internal/modules/cjs/loader.js:746:27)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:93:18)
at Object.<anonymous> (C:\Users\23354\AppData\Roaming\npm\node_modules\npm\node_modules\lru-cache\index.js:4:17)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Module.require (internal/modules/cjs/loader.js:974:19)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:2564) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error
originated either by throwing inside of an async function without a catch block, or by
rejecting a promise which was not handled with .catch(). To terminate the node process
on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see
https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:2564) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated.
In the future, promise rejections that are not handled will terminate the Node.js
process with a non-zero exit code.

I solved this by uninstalling node, and deleting the npm folder in the Roaming folder, then restarted the computer.
After that I installed node again. Everything is working now.

I occurred this problem while yarn build, what I have done the solve the problem are:
rm -rf node_modules
yarn install
yarn build
Btw, my node version is v14.18.1 and I have tried to remove yarn.lock but not worked.

Related

Cyclic.sh is not detecting the start scrypt in package.json

I came here after some hours of reading and getting into the cyclic cool deployment process. https://www.cyclic.sh/
I was trying to host my express js app for free and linked my github repo to my cyclic.sh dashboard. (I added typescript to my express app btw) The build process of my app was successful ✅ , but when I check the logs on runtime it throws me this error: ERROR: Failed to run 'node index.js'
Successful build:
enter image description here
The complete error log in runtime:
2023-01-09 01:21:26.063: grep: /var/task/package.json: No such file or directory
2023-01-09 01:21:26.527: node:internal/modules/cjs/loader:998
throw err;
^
Error: Cannot find module 'dotenv'
Require stack:
- /var/task/index.js
at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
at Module._load (node:internal/modules/cjs/loader:841:27)
at Module.require (node:internal/modules/cjs/loader:1061:19)
at require (node:internal/modules/cjs/helpers:103:18)
at Object.<anonymous> (/var/task/index.js:33:34)
at Module._compile (node:internal/modules/cjs/loader:1159:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
at Module.load (node:internal/modules/cjs/loader:1037:32)
at Module._load (node:internal/modules/cjs/loader:878:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/var/task/index.js' ]
}
Thrown at:
at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
at Module._load (node:internal/modules/cjs/loader:841:27)
at Module.require (node:internal/modules/cjs/loader:1061:19)
2023-01-09 01:21:26.527: at require (node:internal/modules/cjs/helpers:103:18)
at /var/task/index.js:33:34
at Module._compile (node:internal/modules/cjs/loader:1159:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
at Module.load (node:internal/modules/cjs/loader:1037:32)
at Module._load (node:internal/modules/cjs/loader:878:12)
at executeUserEntryPoint (node:internal/modules/run_main:81:12)
Node.js v18.12.1
2023-01-09 01:21:26.562:
ERROR: Failed to run 'node index.js'.
Exited with code: 1
I noticed that the problem is that cyclic is not running node in the correct directory. The correct command executed should be: node dist/index.js. Because of that, I added the scripts configuration in my package.json as it is specified in https://docs.cyclic.sh/overview/launch, but for some reason cyclic is not reading that change in my scripts. (It works well locally)
I am not sure if I am missing something. I am very close, but I am stock at this point. I attatched some screenshots about the successful build, the failure and my package.json configuration.
My package.json file configuration:
enter image description here
Any help would be very appreaciated! Thanks in advance!

Error being displayed while setting up react native development environment

After typing 'npm start' instead of getting QR code on the terminal I am getting a 'UnhandledPromiseRejectionWarning' error. Can please someone help me resolve this? I am a beginner at this so I dont know the meaning of errors being displayed
C:\Users\DELL\Desktop\project> npm run android
> project#1.0.0 android C:\Users\DELL\Desktop\project
> expo start --android
(node:3460) UnhandledPromiseRejectionWarning: Error: Cannot find module 'fs/promises'
Require stack:
- C:\Users\DELL\Desktop\project\node_modules\#expo\cli\build\src\start\doctor\typescript\TypeScriptProjectPrerequisite.js
- C:\Users\DELL\Desktop\project\node_modules\#expo\cli\build\src\start\startAsync.js
- C:\Users\DELL\Desktop\project\node_modules\#expo\cli\build\src\start\index.js
- C:\Users\DELL\Desktop\project\node_modules\#expo\cli\build\bin\cli
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:962:15)
at Function.Module._load (internal/modules/cjs/loader.js:838:27)
at Module.require (internal/modules/cjs/loader.js:1022:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (C:\Users\DELL\Desktop\project\node_modules\#expo\cli\build\src\start\doctor\typescript\TypeScriptProjectPrerequisite.js:5:40)
at Module._compile (internal/modules/cjs/loader.js:1118:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1138:10)
at Module.load (internal/modules/cjs/loader.js:982:32)
at Function.Module._load (internal/modules/cjs/loader.js:875:14)
at Module.require (internal/modules/cjs/loader.js:1022:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (C:\Users\DELL\Desktop\project\node_modules\#expo\cli\build\src\start\startAsync.js:15:38)
at Module._compile (internal/modules/cjs/loader.js:1118:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1138:10)
at Module.load (internal/modules/cjs/loader.js:982:32)
at Function.Module._load (internal/modules/cjs/loader.js:875:14)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:3460) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either
by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:3460) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
PS C:\Users\DELL\Desktop\project>

Error when starting metro server in Vscode

When I try to start metro server using yarn start, this error comes:
PS C:\Users\SAMSUNG\Desktop\myApp> yarn start
yarn run v1.22.17
warning ..\..\..\package.json: No license field
$ react-native start
error Cannot read properties of undefined (reading 'split').
TypeError: Cannot read properties of undefined (reading 'split')
at toIdentifier (C:\Users\SAMSUNG\Desktop\myApp\node_modules\toidentifier\index.js:26:6)
at forEachCode (C:\Users\SAMSUNG\Desktop\myApp\node_modules\http-errors\index.js:267:16)
at Array.forEach (<anonymous>)
at populateConstructorExports (C:\Users\SAMSUNG\Desktop\myApp\node_modules\http-errors\index.js:265:9)
at Object.<anonymous> (C:\Users\SAMSUNG\Desktop\myApp\node_modules\http-errors\index.js:31:1)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
info Run CLI with --verbose flag for more details.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
What is wrong?
PS: It was working before without any problem. I upgraded all the node modules inside project and also react-native version, and this error started to happen. I didn't do anything to node.js, it is the same as before(v16.14.0).

Unable to upgrade ReactNative from version 0.59.x to the latest version, 0.64.x

I am upgrading my ReactNative project to the latest ReactNative version. My project is currently using ReactNative version, 0.59.10. I am upgrading it to the version, 0.64.2.
I run the following command in the project's root directory.
npx react-native upgrade
When I run the command, I am getting the following error.
info No version passed. Fetching latest...
info Fetching diff between v0.59.10 and v0.64.2...
info Applying diff...
warn Excluding files that exist in the template, but not in your project:
error Automatically applying diff failed. We did our best to automatically upgrade as many files as possible
warn Continuing after failure. Some of the files are upgraded but you will need to deal with conflicts manually
info Installing "react-native#0.64.2" and its peer dependencies...
(node:37101) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'close' of undefined
at Object.<anonymous> (/Users/xandasupport/Desktop/Wais/pcl-app/node_modules/chalk/index.js:72:75)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at _chalk (/Users/xandasupport/Desktop/Wais/pcl-app/node_modules/#react-native-community/cli/build/cliEntry.js:22:39)
at handleError (/Users/xandasupport/Desktop/Wais/pcl-app/node_modules/#react-native-community/cli/build/cliEntry.js:106:46)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:37101) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3)
(node:37101) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
I am using Node JS version, v12.22.1. I tried using version, 14 too. I am still getting the same error. How can I fix it?

Error: Cannot find module 'wrappy'

When I try to restore my packages via yarn I'm receiving the following error:
npm run yarn --ignore-platform --ignore-optional
...
error C:\Users\mdepouw\source\repos\MyRepo\node_modules\node-sass: Command failed.
Exit code: 1
Command: node scripts/install.js
Arguments:
Directory: C:\Users\mdepouw\source\repos\MyRepo\node_modules\node-sass
Output:
module.js:471
throw err;
^
Error: Cannot find module 'wrappy'
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\mdepouw\source\repos\MyRepo\node_modules\inflight\inflight.js:1:76)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
When I a npm install it works fine.
Why does one work but not the other?
This usually happens when you update npm. To resolve this go to path "C:\Users[username]\AppData\Roaming" and delete "npm" and "npm-cache" folders. Then uninstall nodejs and reinstall using updated installer. This should solve your problem.