yeoman generator fails: "Cannot find module 'download'" - npm

I've uninstalled and reinstalled yo and download using npm. And switched to node 10.28 and node 11.14 but when I try and run a yo generator I keep getting:
module.js:333
throw err;
^
Error: Cannot find module 'download'
at Function.Module._resolveFilename (module.js:331:15)
at Function.Module._load (module.js:273:25)
at Module.require (module.js:357:17)
at require (module.js:373:17)
at Object.<anonymous> (/usr/local/share/npm/lib/node_modules/yo/node_modules/yeoman-generator/lib/actions/fetch.js:5:16)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:349:32)
at Function.Module._load (module.js:305:12)
at Module.require (module.js:357:17)
I tried uninstalling / re-installing npm, yeoman, node, and the generator, plus googling and trying random things - nothing seemed to help.
Solution:
After some time fiddling - this fixed it:
cd /usr/local/share/npm/lib/
npm i download && npm update

Reinstall the latest version?
I don't know what went wrong here, but a module is missing. It might be because of the way you're changing the node version (it might change the path to node modules). Or it might be an installation error, make sure to read through the npm install logs.

I had this same problem on a version of node that I installed with brew and then upgraded (several months later) using brew upgrade node. I fixed it by running brew uninstall --force node to remove all the versions of node and then running brew install node and npm install -g yo generator-kraken bower grunt-cli again. This may have happened as a result of having multiple versions of node installed, as reported by brew when I attempted to unistall node the first time (output below).
brew uninstall node
Uninstalling /usr/local/Cellar/node/4.2.1... (2738 files, 36M)
node 0.10.29 is still installed.
Remove them all with `brew uninstall --force node`.

"npm i download" never worked for me at all. With "npm install -g download" I solved definitely my problem followed, as suggested, by "npm update".

Related

npm v9.4.0 is known not to run on Node.js v19.5.0

I somehow broke npm on my Windows system. Any (literally any) npm command I use gives me the following illogical error:
ERROR: npm v9.4.0 is known not to run on Node.js v19.5.0. You'll need to upgrade to a newer Node.js version in order to use this version of npm. This version of npm supports the following node versions: ^14.17.0 || ^16.13.0 || >=18.0.0. You can find the latest version at https://nodejs.org/.
ERROR: C:\Users\PCName\AppData\Roaming\npm\node_modules\npm\node_modules\#npmcli\arborist:1 ../../workspaces/arborist SyntaxError: Unexpected token '.' at internalCompileFunction (node:internal/vm:73:18) at wrapSafe (node:internal/modules/cjs/loader:1166:20) at Module._compile (node:internal/modules/cjs/loader:1210:27) at Module._extensions..js (node:internal/modules/cjs/loader:1300:10) at Module.load (node:internal/modules/cjs/loader:1103:32) at Module._load (node:internal/modules/cjs/loader:942:12) at Module.require (node:internal/modules/cjs/loader:1127:19) at require (node:internal/modules/helpers:112:18) at Object.<anonymous> (C:\Users\PCName\AppData\Roaming\npm\node_modules\npm\lib\npm.js:1:18) at Module._compile (node:internal/modules/cjs/loader:1246:14)
I tried uninstalling and re-install node.
I deleted the npm folder in C:\Users\PCName\AppData\Roaming\npm\node_modules, downloaded the latest version here: https://github.com/npm/cli/releases/tag/v9.4.0, extracted it, renamed it to 'npm', and copied it to the folder where I deleted it.
I fixed this on my machine by downloading the node installer from https://nodejs.org/en/download/ I did not even bother to uninstall my existing node.
Caveat: After doing this, nvm stopped working. When I do nvm use XXXX it says that it switched versions but it did not.

React install problems with npm

When I run npx create-react-app, I had these errors. Maybe someone knows whats it's wrong? P.S. also had tried npm-install -g create-react-app.
C:\Users\Deividas\Desktop\PAMEGINIMAS>create-react-app my-app
internal/modules/cjs/loader.js:621
throw e;
^
Error: No valid exports main found for 'C:\Users\Deividas\AppData\Roaming\npm\node_modules\create-react-app\node_modules\is-promise'
at resolveExportsTarget (internal/modules/cjs/loader.js:618:9)
at applyExports (internal/modules/cjs/loader.js:499:14)
at resolveExports (internal/modules/cjs/loader.js:548:12)
at Function.Module._findPath (internal/modules/cjs/loader.js:650:22)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:948:27)
at Function.Module._load (internal/modules/cjs/loader.js:854:27)
at Module.require (internal/modules/cjs/loader.js:1023:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (C:\Users\Deividas\AppData\Roaming\npm\node_modules\create-react-app\node_modules\run-async\index.js:3:17)
at Module._compile (internal/modules/cjs/loader.js:1128:30) {
code: 'MODULE_NOT_FOUND'
}
This seems to be a recent problem with npm. There is an issue open as of the last few hours and it seems like people are working on it. I don't think it's anything to do with yourproject.
The issue
While the issue is being fixed: try installing node version 12.12.0 as shown below (if using nvm) and run create-react-app again.
nvm install 12.12.0
nvm use 12.12.0
I'd try to clear your cache npm cache clean --force. What version of node and npm are you using?

"react-native start" command gives error

react-native start command gives error.Genrated error is given below. Please help me.
react-native start
/usr/lib/node_modules/react-native/local-cli/server/checkNodeVersion.js:43
);
^
SyntaxError: Unexpected token )
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:549:28)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
at Module.require (module.js:504:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/lib/node_modules/react-native/local-cli/cli.js:17:1)
I found out that if you have installed nvm to manage different node versions, is showing one version but using another from behind, I also have problems with my global brew node installation, so I had reinstalled again from scratch. As a general tip, unload the nvm and work with the npm global installation.
Update your nodejs should fix
sudo npm cache clean -f (force) clear you npm cache
sudo npm install -g n install "n" (this might take a while)
sudo n stable upgrade to lastest version
I checked the file "/usr/lib/node_modules/react-native/local-cli/server/checkNodeVersion.js:43" and found that "React Native runs on Node 8.0 or newer."
But my node vesion was 6.0 ,so that the problem.
The error belongs with node js version.
node --v in cmd will show version less than 8.
Update your node version by installing nvm. This will help you update version.
https://stackoverflow.com/a/7718438/9090200
In-case you are using nvm to install a new version of node.
It's important that you will use nvm alias default node so it will be the default version while opening new shells.
React Native runs on Node 8.0 or newer
If you are using nvm then set "nvm alias default >=8.X.X" like "nvm alias default 8.0.0"
Re-open your terminal and try it again.

Cannot find module 'npmlog'

Hello I receive the following message when trying to install npm. I downloaded the most recent node.js but it doesn't seem to download npm. I keep getting the belowenter code here error message after deleting node.js and reinstalling it.
When I try installing node.js I don't see the following being created:
C:\Users\Efren Barragan\AppData\Roaming\npm
This is the first time installing node.js. I just installed it on my old computer and it worked out fine. I am new to this so so your patience is much appreciated! Thanks!
C:\Users\Efren Barragan> npm install npm -g
module.js:327
throw err;
^
Error: Cannot find module 'npmlog'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at C:\Users\Efren Barragan\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js:19:13
at Object.<anonymous> (C:\Users\Efren Barragan\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js:75:3)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
Due to the bug in versions this is what i did -
I have faced the same issue in my Windows 10 PC. After looking into solutions, since i couldn't find the exact solution for the issue i was facing
Cannot find module 'npmlog'
I just uninstalled the node js and then, deleted both 'npm' and 'npm-cache' in
"C:\Users\YourPCName\AppData\Roaming"
Then, i downloaded the latest version of node from Node JS Website
And, installed node js
After that i checked with the path in environment variables.
Finally run the command prompt 'run as administrator' and npm install npm -g
Checking your version will show the latest version. 'npm -v'
I got the latest version - v3.10.9
Try this. this should work.
Install a newer version, it's been a bug in previous version.

karma start Cannot find module 'jasmine-core'

I was getting the following error when I ran "karma start"
module.js:340
throw err;
^
Error: Cannot find module 'jasmine-core'
at Function.Module._resolveFilename (module.js:338:15)
at Function.require.resolve (module.js:384:19)
at initJasmine (/usr/lib/node_modules/karma-jasmine/lib/index.js:8:42)
at Array.invoke [as 0] (/usr/lib/node_modules/karma/node_modules/di/lib/injector.js:75:15)
at get (/usr/lib/node_modules/karma/node_modules/di/lib/injector.js:48:43)
at /usr/lib/node_modules/karma/lib/server.js:137:20
at Array.forEach (native)
at Server._start (/usr/lib/node_modules/karma/lib/server.js:136:21)
at invoke (/usr/lib/node_modules/karma/node_modules/di/lib/injector.js:75:15)
at Server.start (/usr/lib/node_modules/karma/lib/server.js:101:18)
at Object.exports.run (/usr/lib/node_modules/karma/lib/cli.js:231:26)
at Object. (/usr/lib/node_modules/karma/bin/karma:3:23)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
Does anyone know why this is happening? I was running karma in a VM. I tried several npm install commands and nothing worked. After I shutdown my machine for the night and came back the next day the problem went away and everything is working again. So, I'm not blocked anymore.. Anyone have some thoughts on what could be happening?
I solved using npm install jasmine-core --save-dev
try install jasmine-core globally (Jasmine on NPM).
use npm install -g jasmine-core
Even with karma and karma-jasmine installed in the local project's node_modules you must still npm install jasmine.
So for a fresh Karma project:
npm install karma karma-jasmine jasmine to install the required modules locally.
Optionally add --save-dev to write to your package.json.
Note these do not need to be -g globally installed here.
karma start
This step requires you to have Karma installed globally (sudo npm install -g karma).
Navigate to folder:
cd node_modules\karma-jasmine
Run:
npm install
This should download the required dependencies and fix the issue.
Also, it is important to know the installation path where do you have karma.conf.js file.
I have this problem, and have tried every suggestion on the page without it fixing the problem. Well, I haven't yet rebooted, so I'll try that next, but I have closed my shell (git-bash) and re-opened it in case it was an environment variable problem. Something is wrong here and I don't think the problem has been identified yet.