简体   繁体   English

yeoman生成器失败:“找不到模块'下载'”

[英]yeoman generator fails: “Cannot find module 'download'”

I've uninstalled and reinstalled yo and download using npm. 我已经卸载并重新安装了yo并使用npm download And switched to node 10.28 and node 11.14 but when I try and run a yo generator I keep getting: 并切换到node 10.28node 11.14但是当我尝试运行yo发电机时,我不断得到:

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. 我尝试卸载/重新安装npm,yeoman,节点和生成器,以及使用Google搜寻和尝试随机操作-似乎无济于事。

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. 否则可能是安装错误,请确保通读npm安装日志。

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 . 我在brew上安装并随后使用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. 我通过运行brew uninstall --force node brew install node brew uninstall --force node以删除该brew uninstall --force node所有版本,然后运行brew install node并再次运行brew install node npm install -g yo generator-kraken bower grunt-cli 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所报告的那样,这可能是由于安装了多个版本的节点而发生的(下面的输出)。

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. “ npm我下载”对我完全没有用。 With "npm install -g download" I solved definitely my problem followed, as suggested, by "npm update". 通过“ npm install -g download”,我确实解决了我的问题,正如建议的那样,接着是“ npm update”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM