我无法使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
如有任何见解,我们将不胜感激。
首先,确保npm install -g firebase-tools
的安装过程成功完成。如果问题仍然存在,重建grpc模块应该可以解决您的问题。请运行npm rebuild grpc
。您也可以通过运行npm rebuild
来重建所有模块。