我刚刚通过google-translate-api
和npm
安装了npm install --save google-translate-api
。我没有收到任何错误消息,但是当我尝试运行npm start
时,它显示了以下错误:
ERROR in ./node_modules/got/index.js
Module not found: Error: Can't resolve './package' in '/home/zolastro/Documents/Work/GenEnginePMV/genengine/GenEngine/node_modules/got'
ERROR in ./node_modules/osenv/osenv.js
Module not found: Error: Can't resolve 'child_process' in '/home/zolastro/Documents/Work/GenEnginePMV/genengine/GenEngine/node_modules/osenv'
ERROR in ./node_modules/graceful-fs/polyfills.js
Module not found: Error: Can't resolve 'constants' in '/home/zolastro/Documents/Work/GenEnginePMV/genengine/GenEngine/node_modules/graceful-fs'
ERROR in ./node_modules/graceful-fs/fs.js
Module not found: Error: Can't resolve 'fs' in '/home/zolastro/Documents/Work/GenEnginePMV/genengine/GenEngine/node_modules/graceful-fs'
ERROR in ./node_modules/graceful-fs/graceful-fs.js
Module not found: Error: Can't resolve 'fs' in '/home/zolastro/Documents/Work/GenEnginePMV/genengine/GenEngine/node_modules/graceful-fs'
ERROR in ./node_modules/mkdirp/index.js
Module not found: Error: Can't resolve 'fs' in '/home/zolastro/Documents/Work/GenEnginePMV/genengine/GenEngine/node_modules/mkdirp'
ERROR in ./node_modules/got/index.js
Module not found: Error: Can't resolve 'http' in '/home/zolastro/Documents/Work/GenEnginePMV/genengine/GenEngine/node_modules/got'
ERROR in ./node_modules/got/index.js
Module not found: Error: Can't resolve 'https' in '/home/zolastro/Documents/Work/GenEnginePMV/genengine/GenEngine/node_modules/got'
ERROR in ./node_modules/os-homedir/index.js
Module not found: Error: Can't resolve 'os' in '/home/zolastro/Documents/Work/GenEnginePMV/genengine/GenEngine/node_modules/os-homedir'
ERROR in ./node_modules/configstore/index.js
Module not found: Error: Can't resolve 'path' in '/home/zolastro/Documents/Work/GenEnginePMV/genengine/GenEngine/node_modules/configstore'
ERROR in ./node_modules/mkdirp/index.js
Module not found: Error: Can't resolve 'path' in '/home/zolastro/Documents/Work/GenEnginePMV/genengine/GenEngine/node_modules/mkdirp'
ERROR in ./node_modules/osenv/osenv.js
Module not found: Error: Can't resolve 'path' in '/home/zolastro/Documents/Work/GenEnginePMV/genengine/GenEngine/node_modules/osenv'
ERROR in ./node_modules/xdg-basedir/index.js
Module not found: Error: Can't resolve 'path' in '/home/zolastro/Documents/Work/GenEnginePMV/genengine/GenEngine/node_modules/xdg-basedir'
ERROR in ./node_modules/duplexer3/index.js
Module not found: Error: Can't resolve 'stream' in '/home/zolastro/Documents/Work/GenEnginePMV/genengine/GenEngine/node_modules/duplexer3'
ERROR in ./node_modules/get-stream/buffer-stream.js
Module not found: Error: Can't resolve 'stream' in '/home/zolastro/Documents/Work/GenEnginePMV/genengine/GenEngine/node_modules/get-stream'
ERROR in ./node_modules/got/index.js
Module not found: Error: Can't resolve 'stream' in '/home/zolastro/Documents/Work/GenEnginePMV/genengine/GenEngine/node_modules/got'
ERROR in ./node_modules/graceful-fs/legacy-streams.js
Module not found: Error: Can't resolve 'stream' in '/home/zolastro/Documents/Work/GenEnginePMV/genengine/GenEngine/node_modules/graceful-fs'
ERROR in ./node_modules/safe-eval/index.js
Module not found: Error: Can't resolve 'vm' in '/home/zolastro/Documents/Work/GenEnginePMV/genengine/GenEngine/node_modules/safe-eval'
我还读到我的package.json
中可能是一个sintax错误,但是我看不到任何错误。以防万一,这是我的package.json
文件:
{
"name": "gen-engine-web-app",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^6.0.3",
"@angular/cdk": "^6.2.0",
"@angular/common": "^6.0.3",
"@angular/compiler": "^6.0.3",
"@angular/core": "^6.0.3",
"@angular/forms": "^6.0.3",
"@angular/http": "^6.0.3",
"@angular/material": "^6.2.0",
"@angular/platform-browser": "^6.0.3",
"@angular/platform-browser-dynamic": "^6.0.3",
"@angular/router": "^6.0.3",
"@ng-select/ng-select": "^2.1.3",
"angular-font-awesome": "^3.1.2",
"angularfire2": "^5.0.0-rc.10",
"core-js": "^2.5.4",
"firebase": "^5.0.4",
"font-awesome": "^4.7.0",
"rxjs": "^6.0.0",
"rxjs-compat": "^6.2.0",
"zone.js": "^0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.6.6",
"@angular/cli": "~6.0.7",
"@angular/compiler-cli": "^6.0.3",
"@angular/language-service": "^6.0.3",
"@types/jasmine": "~2.8.6",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"codelyzer": "~4.2.1",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "^2.0.2",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.0",
"karma-jasmine": "~1.1.1",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.3.0",
"ts-node": "~5.0.1",
"tslint": "~5.9.1",
"typescript": "~2.7.2"
}
}
请注意,我正在使用Angular 6,但没有Webpack配置文件(我已经阅读了有关该文件的几种解决方案)。有人可以帮我解决这个问题吗?
答案 0 :(得分:1)
我还远不是Angular的专家,但在将Ionic 3应用程序(使用TypeORM)升级到Ionic 4以及从Angular 5升级到Angular 6时遇到了同样的问题。
我认为问题出在某些外部库(在您的情况下可能是google-translate-api-在我的情况下显然是TypeORM),这些外部库尚未“准备好”在Angular 6应用程序中使用。在https://github.com/angular/angular-cli/issues/9827#issuecomment-369578814中可以找到更详细且可能更正确的解释。
我首先尝试安装具有相同名称的软件包,并且在大多数情况下有帮助,但是如https://github.com/DevExpress/devextreme-angular/issues/776#issuecomment-399344876所述,不建议这样做。
更好的方法是替换https://github.com/stellar/js-stellar-base/issues/128#issuecomment-391374590中描述的node_modules / @ angular-devkit中的文件。
最后,我仍然遇到“ hiredis”(特定于TypeORM)错误:
gq https://gentle-anchorage-72051.herokuapp.com/v1alpha1/graphql -i
在我看来,这是可选的,因此我打开了文件,并注释了需求声明及其每次使用。
此解决方案并不令人满意,因为它需要更改node_modules文件夹中的文件,但是目前我认为这可能是在受影响的库尚未“ Angular 6就绪”时使用的解决方法。
关于, 丹尼斯