Error: Cannot find module 'shrink-ray'

Error: Cannot find module 'shrink-ray'

在使用了神奇的angular-fullstack-generator though Yeoman之后,我按照设置说明进行操作,当我来到运行npm startgulp serve时,我得到了以下错误:

Error: Cannot find module 'shrink-ray'

似乎不​​言自明,所以我 运行 npm install shrink-ray,这样做给了我以下错误:

node-pre-gyp ERR! Tried to download(403): https://node-zopfli.s3.amazonaws.com/Releas
e/zopfli-v1.4.0-node-v48-win32-x64.tar.gz                                            
node-pre-gyp ERR! Pre-built binaries not found for node-zopfli@1.4.0 and node@6.9.2 (
node-v48 ABI) (falling back to source compile with node-gyp)                         
Building the projects in this solution one at a time. To enable parallel build, pleas
e add the "/m" switch.                                                               
MSBUILD : error MSB3428: Could not load the Visual C++ component "VCBuild.exe". To f 
ix this, 1) install the .NET Framework 2.0 SDK, 2) install Microsoft Visual Studio 2 
005 or 3) add the location of the component to the system path if it is installed el 
sewhere.  [C:\Users\alicia.sykes\Dropbox\Coding\Angular\team-awesome\node_modules\no 
de-zopfli\build\binding.sln]       

同样,这个错误看起来很明显,所以我按照它建议的步骤进行操作 - 但它没有用。总是返回同样的错误,阻止我安装 shrink-ray.

经过几个小时的谷歌搜索,它看起来像是以下问题的组合:

其中一些因素修改了错误消息 - 但 none 是解决方案。

The solution was in fact simple:

(as admin/sudo) run: npm install --global --production windows-build-tools

This was provided by the very helpful Adonay28 on this GitHub issue, here: https://github.com/angular-fullstack/generator-angular-fullstack/issues/2462#issuecomment-275112118

为此,您还需要具备:

  • Python 已安装 2.7 或 3.1
  • 最新版本的 npm(4.5.0 有效)。 运行: npm i npm -g 更新。
  • 并且全局安装了 node-gyp。 运行npm install -g node-gyp

希望这对其他人有帮助,让应用程序 运行 更快,谢谢,我做到了!