我们正在一个项目中,该项目连接到Google语音到文本和AWS等服务,在本地运行时一切正常,但是在Azure端部署失败,出现非常奇怪的错误:
Running 'npm install' ...
> grpc@1.19.0 install /home/site/wwwroot/node_modules/grpc
> node-pre-gyp install --fallback-to-build --library=static_library
internal/modules/cjs/loader.js:583
throw err;
^
Error: Cannot find module '../'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (/home/site/wwwroot/node_modules/grpc/node_modules/node-pre-gyp/bin/node-pre-gyp:15:20)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
npm WARN rollback Rolling back fs-minipass@1.2.5 failed (this is probably harmless): ENOTEMPTY: directory not empty, rmdir '/home/site/wwwroot/node_modules/grpc/node_modules/fs-minipass'
npm WARN rollback Rolling back wide-align@1.1.3 failed (this is probably harmless): ENOTEMPTY: directory not empty, rmdir '/home/site/wwwroot/node_modules/grpc/node_modules/wide-align'
然后是许多ENOTEMPTY:目录不为空的错误。在本地运行时不会发生这些错误。
至于“目录不为空”,我们阅读了一些有关禁用病毒软件并关闭某些正在运行但无济于事的应用程序的文章。我们不明白为什么Azure或npm都假定“ ../”是模块,也不是。
当我们部署与Google相关的东西时,问题开始发生,在那之前一切正常:
class Google {
async getTextFromAudio(audioFile) {
const client = new speech.SpeechClient();
const audio = {
content: audioFile
};
const config = {
encoding: 'FLAC',
languageCode: 'is-IS'
};
const request = {
audio: audio,
config: config
}
const [response] = await client.recognize(request);
const transcription = response.results
.map(result => result.alternatives[0].transcript)
.join('\n');
return transcription;
}
}
module.exports = Google;
我们尚未为Azure设置google凭据,因此我们期待与此相关的错误,它无法达到目标,并且似乎在达到目标之前会出错。我们甚至尝试删除导致这些错误的代码,然后再次部署,但是并不能解决该错误。还有其他人遇到类似的错误吗?