问题
I trying to run my Nativescript project but I keep getting the following error regarding 'async_hooks' in bluebird (^v3.7.2). I have no idea what to do to start resolving this issue. Any help would be much appreciated.
ERROR in ../node_modules/bluebird/js/release/promise.js
Module not found: Error: Can't resolve 'async_hooks' in '/Users/.../node_modules/bluebird/js/release'
@ ../node_modules/bluebird/js/release/promise.js 34:4-26
@ ../node_modules/bluebird/js/release/bluebird.js
@ ./app/components/pages/session/session.service.ts
@ ./app/components/pages/session/session.component.ts
@ ./app/components/pages/index.ts
@ ./app/components/components.module.ts
@ ./app/app.module.ts
@ ./main.ts
Both the session.component.ts and the session.service.ts use an async and await call. Specificaly, there is one method that is labeled async with an await inside of it. My zone.js is also ~0.11.3. Below is my tsconfig.
{
"compilerOptions": {
"module": "esnext",
"target": "es2017",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"noEmitHelpers": true,
"noEmitOnError": true,
"skipLibCheck": true,
"lib": [
"es2018", "es2017", "dom", "es6"
],
"baseUrl": ".",
"paths": {
"~/*": [
"src/*"
]
}
},
"include": [
"src/tests/**/*.ts",
"src/**/*.ios.ts",
"src/**/*.android.ts"
],
"files": [
"./references.d.ts",
"./src/main.ts"
],
"exclude": [
"node_modules",
"platforms",
"e2e"
]
}
This is on Nativescript 7, Angular 11, node (v10.15.0).
Below is my package json
"dependencies": {
"@angular/animations": "~11.0.0",
"@angular/cdk": "^11.0.3",
"@angular/common": "~11.0.0",
"@angular/compiler": "~11.0.0",
"@angular/core": "~11.0.0",
"@angular/forms": "~11.0.0",
"@angular/material": "^11.0.3",
"@angular/platform-browser": "~11.0.0",
"@angular/platform-browser-dynamic": "~11.0.0",
"@angular/router": "~11.0.0",
"@nativescript-community/ble": "^3.0.13",
"@nativescript/angular": "~11.0.0",
"@nativescript/camera": "^5.0.2",
"@nativescript/core": "~7.0.0",
"@nativescript/theme": "~3.0.0",
"@sentry/node": "^5.29.0",
"bluebird": "^3.7.2",
"crypto-js": "^4.0.0",
"hammerjs": "^2.0.8",
"nativescript-imagepicker": "^7.1.0",
"nativescript-insomnia": "^2.0.0",
"nativescript-purchase": "^2.0.14",
"nativescript-sentry": "^2.0.0",
"nativescript-toasty": "^3.0.0-alpha.2",
"nativescript-ui-chart": "^8.0.2",
"nativescript-ui-gauge": "^7.0.2",
"nativescript-ui-sidedrawer": "9.0.3",
"nativescript-urlhandler": "^1.3.0",
"node-sass": "^4.14.1",
"reflect-metadata": "~0.1.12",
"rxjs": "^6.6.0",
"zone.js": "~0.11.3"
},
"devDependencies": {
"@angular/compiler-cli": "~11.0.0",
"@nativescript/android": "7.0.1",
"@nativescript/ios": "7.0.1",
"@nativescript/types": "~7.0.0",
"@nativescript/webpack": "~3.0.0",
"@ngtools/webpack": "~11.0.0",
"typescript": "~4.0.0"
},
SOLVED: Had to revert back my bluebird version to 3.5.5 as recommended by this git issue https://github.com/petkaantonov/bluebird/issues/1617
来源:https://stackoverflow.com/questions/65570898/cant-resolve-async-hooks-in-bluebird-in-nativescript-project