Angular 9通用服务器端渲染GRPC错误

时间:2020-02-18 02:27:02

标签: angular firebase angular-universal

我无法让npm run build:ssr && npm run serve:ssr正常运行。

我已通过以下方式将Angular Universal添加到我的项目中:ng add @nguniversal/express-engine --clientProject SampleAngularApp

npm run build:ssr可以完美地运行和构建,而npm run serve:ssr则不能完美运行。

这是我尝试服务器时的错误:

Error: Cannot find module '/Users/mike/Desktop/Sites/SampleAngularApp/node_modules/grpc/src/node/extension_binary/node-v72-darwin-x64-unknown/grpc_node.node'
Require stack:
- /Users/mike/Desktop/Sites/SampleAngularApp/node_modules/grpc/src/grpc_extension.js
- /Users/mike/Desktop/Sites/SampleAngularApp/node_modules/grpc/src/client_interceptors.js
- /Users/mike/Desktop/Sites/SampleAngularApp/node_modules/grpc/src/client.js
- /Users/mike/Desktop/Sites/SampleAngularApp/node_modules/grpc/index.js
- /Users/mike/Desktop/Sites/SampleAngularApp/node_modules/@firebase/firestore/dist/index.node.cjs.js
- /Users/mike/Desktop/Sites/SampleAngularApp/node_modules/firebase/firestore/dist/index.cjs.js
- /Users/mike/Desktop/Sites/SampleAngularApp/dist/server.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:625:15)
    at Function.Module._load (internal/modules/cjs/loader.js:527:27)
    at Module.require (internal/modules/cjs/loader.js:683:19)
    at require (internal/modules/cjs/helpers.js:16:16)
    at Object.<anonymous> (/Users/mike/Desktop/Sites/SampleAngularApp/node_modules/grpc/src/grpc_extension.js:32:13)
    at Module._compile (internal/modules/cjs/loader.js:777:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:788:10)
    at Module.load (internal/modules/cjs/loader.js:643:32)
    at Function.Module._load (internal/modules/cjs/loader.js:556:12)
    at Module.require (internal/modules/cjs/loader.js:683:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/mike/Desktop/Sites/SampleAngularApp/node_modules/grpc/src/grpc_extension.js',
    '/Users/mike/Desktop/Sites/SampleAngularApp/node_modules/grpc/src/client_interceptors.js',
    '/Users/mike/Desktop/Sites/SampleAngularApp/node_modules/grpc/src/client.js',
    '/Users/mike/Desktop/Sites/SampleAngularApp/node_modules/grpc/index.js',
    '/Users/mike/Desktop/Sites/SampleAngularApp/node_modules/@firebase/firestore/dist/index.node.cjs.js',
    '/Users/mike/Desktop/Sites/SampleAngularApp/node_modules/firebase/firestore/dist/index.cjs.js',
    '/Users/mike/Desktop/Sites/SampleAngularApp/dist/server.js'
  ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sample-angular-app@0.0.0 serve:ssr: `node dist/server`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the sample-angular-app@0.0.0 serve:ssr script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/mike/.npm/_logs/2020-02-18T02_17_14_016Z-debug.log

任何见识将不胜感激。

1 个答案:

答案 0 :(得分:0)

首先,请确保npm install -g firebase-tools的安装过程成功完成。如果问题仍然存在,则重建grpc模块应该可以解决您的问题。请运行npm rebuild grpc。您还可以通过运行npm rebuild来重建所有模块。