我一点点在这一个困惑,所以这里有云:需要@谷歌云/语言中断的WebPack(“模块未找到”)
我试图做一个搜索栏一个作出反应的应用这将呼吁谷歌的自然语言API(https://cloud.google.com/natural-language/),作为我的一部分,当然安装了'@谷歌云/语言'包。然而,当我尝试要求它在任何文件(我的具体情况是const Language = require('@google-cloud/language');
),然后尝试运行webpack-dev-server,它无法找到...我认为任何我的模块?严格地讲,它只是一个巨大的墙“模块未找到”的错误,如
Error in ./~/grpc/~/node-pre-gyp/lib/info.js
Module not found: 'aws-sdk' in /home/amberb/projects/project-ui/node_modules/grpc/node_modules/node-pre-gyp/lib
@ ./~/grpc/~/node-pre-gyp/lib/info.js 14:14-32
Error in ./~/grpc/~/node-pre-gyp/lib/publish.js
Module not found: 'aws-sdk' in /home/amberb/projects/project-ui/node_modules/grpc/node_modules/node-pre-gyp/lib
@ ./~/grpc/~/node-pre-gyp/lib/publish.js 17:14-32
Error in ./~/grpc/~/node-pre-gyp/lib/unpublish.js
Module not found: 'aws-sdk' in /home/amberb/projects/project-ui/node_modules/grpc/node_modules/node-pre-gyp/lib
@ ./~/grpc/~/node-pre-gyp/lib/unpublish.js 15:14-32
Error in /usr/lib/~/npm/bin/npm-cli.js
Module parse failed: /usr/lib/node_modules/npm/bin/npm-cli.js Unexpected character '#' (1:0)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected character '#' (1:0)
@ /usr/lib/~/npm/lib/npm.js 453:4-32
Error in /usr/lib/~/npm/~/opener/opener.js
Module parse failed: /usr/lib/node_modules/npm/node_modules/opener/opener.js Unexpected character '#' (1:0)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected character '#' (1:0)
@ /usr/lib/~/npm/lib/auth/sso.js 4:13-30
Error in /usr/lib/~/npm/~/JSONStream/index.js
Module parse failed: /usr/lib/node_modules/npm/node_modules/JSONStream/index.js Unexpected character '#' (1:0)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected character '#' (1:0)
@ /usr/lib/~/npm/lib/search/all-package-metadata.js 12:17-38
Error in /usr/lib/~/npm/~/npm-registry-client/lib/initialize.js
Module not found: 'json' in /usr/lib/node_modules/npm/node_modules/npm-registry-client/lib
@ /usr/lib/~/npm/~/npm-registry-client/lib/initialize.js 5:10-36
Error in /usr/lib/~/npm/~/validate-npm-package-name/index.js
Module not found: 'json' in /usr/lib/node_modules/npm/node_modules/validate-npm-package-name
@ /usr/lib/~/npm/~/validate-npm-package-name/index.js 4:15-34
Error in /usr/lib/~/npm/~/pacote/lib/util/opt-check.js
Module not found: 'json' in /usr/lib/node_modules/npm/node_modules/pacote/lib/util
(这个持续一段时间)
这不会发生,每当我不包括@谷歌云/语言。我似乎无法找到任何解释,可能会做什么。有人知道我至少可以尝试一些东西吗?
编辑补充:this question想出了一个建议相关的问题后,我想在我的WebPack配置文件中添加
externals: {
'@google-cloud/language': 'commonjs @google-cloud/language'
}
,但不仅导致我的页面没有加载,并给我webpack:///external_%[email protected]/language%22?:1 Uncaught ReferenceError: require is not defined
。我对Webpack仍然有点新,所以我很积极,我错过了一些东西,但我不确定是什么。