twilio / twilio-node

Node.js helper library
MIT License
1.37k stars 495 forks source link

[Bug]: Module not found. Error polyfills, #1026

Closed mgasniernationex closed 1 week ago

mgasniernationex commented 2 weeks ago

Preflight Checklist

Problem Description

I added twilio on my package and then i did "npm start" . And lot's of error appear :

First i had this error :

Error: src/services/twilio.service.ts:3:24 - error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'allowSyntheticDefaultImports' flag and referencing its default export. import { Twilio } from 'twilio';

So i added in tscondig.js "allowSyntheticDefaultImports".

And then i did npm start again and i had this error :

Error: Module not found: Error: Can't resolve 'assert' in 'C:\Users\mgasnier\source\repos\Nationex - TPSL Mobile\TPSLMobileCapacitor\node_modules\twilio\node_modules\https-proxy-agent\dist'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default. This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:

I have this for a hundred of modules.

This is my package.json and tsconfig.json:


{
  "name": "TPSLMobile2",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "https://ionicframework.com/",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^17.1.3",
    "@angular/cdk": "^17.1.2",
    "@angular/common": "^17.1.3",
    "@angular/core": "^17.1.3",
    "@angular/forms": "^17.1.3",
    "@angular/platform-browser": "^17.1.3",
    "@angular/platform-browser-dynamic": "^17.1.3",
    "@angular/router": "^17.1.3",
    "@awesome-cordova-plugins/app-version": "^6.6.0",
    "@awesome-cordova-plugins/bluetooth-serial": "^6.6.0",
    "@awesome-cordova-plugins/camera": "^6.6.0",
    "@awesome-cordova-plugins/clipboard": "^6.6.0",
    "@awesome-cordova-plugins/core": "^6.6.0",
    "@awesome-cordova-plugins/device": "^6.6.0",
    "@awesome-cordova-plugins/file": "^6.6.0",
    "@awesome-cordova-plugins/geolocation": "^6.6.0",
    "@awesome-cordova-plugins/insomnia": "^6.6.0",
    "@awesome-cordova-plugins/native-audio": "^6.6.0",
    "@awesome-cordova-plugins/network": "^6.6.0",
    "@awesome-cordova-plugins/screen-orientation": "^6.6.0",
    "@awesome-cordova-plugins/sqlite": "^6.6.0",
    "@awesome-cordova-plugins/sqlite-porter": "^6.6.0",
    "@capacitor/android": "^5.7.0",
    "@capacitor/app": "^5.0.6",
    "@capacitor/camera": "^5.0.7",
    "@capacitor/dialog": "^5.0.6",
    "@capacitor/haptics": "^5.0.6",
    "@capacitor/ios": "5.6.0",
    "@capacitor/keyboard": "^5.0.8",
    "@capacitor/network": "^5.0.6",
    "@capacitor/preferences": "^5.0.6",
    "@capacitor/push-notifications": "^5.1.0",
    "@capacitor/screen-orientation": "^5.0.6",
    "@capacitor/status-bar": "^5.0.6",
    "@ionic/angular": "^7.8.6",
    "@ngx-translate/core": "^15.0.0",
    "@ngx-translate/http-loader": "^8.0.0",
    "@transistorsoft/capacitor-background-fetch": "^5.1.1",
    "cmbsdk-cordova": "^1.4.271",
    "com-darryncampbell-cordova-plugin-intent": "https://github.com/mgasniernationex/darryncampbell-cordova-plugin-intent.git",
    "cordova-clipboard": "^1.3.0",
    "cordova-plugin-android-permissions": "^1.1.5",
    "cordova-plugin-app-version": "^0.1.14",
    "cordova-plugin-bluetooth-serial": "^0.4.7",
    "cordova-plugin-camera": "^7.0.0",
    "cordova-plugin-device": "^2.1.0",
    "cordova-plugin-file": "^8.0.1",
    "cordova-plugin-insomnia": "^4.3.0",
    "cordova-plugin-screen-orientation": "^3.0.4",
    "cordova-sqlite-storage": "^6.1.0",
    "ngx-image-compress": "^15.1.6",
    "ngx-spinner": "^16.0.2",
    "rxjs": "^7.8.1",
    "swiper": "^11.1.3",
    "tslib": "^2.6.2",
    "twilio": "^5.1.1",
    "uk.co.workingedge.cordova.plugin.sqliteporter": "^1.1.2",
    "zone.js": "~0.14.3"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^17.1.3",
    "@angular-eslint/builder": "~16.2.0",
    "@angular-eslint/eslint-plugin": "~16.2.0",
    "@angular-eslint/eslint-plugin-template": "~16.2.0",
    "@angular-eslint/template-parser": "~16.2.0",
    "@angular/cli": "^17.1.3",
    "@angular/compiler": "^17.1.3",
    "@angular/compiler-cli": "^17.1.3",
    "@angular/language-service": "^17.1.3",
    "@capacitor/cli": "^5.7.0",
    "@capacitor/core": "^5.7.0",
    "@ionic/angular-toolkit": "^10.0.0",
    "@types/jasmine": "~5.1.1",
    "@types/jasminewd2": "^2.0.13",
    "@types/node": "^20.8.10",
    "@typescript-eslint/eslint-plugin": "6.10.0",
    "@typescript-eslint/parser": "6.10.0",
    "eslint-plugin-import": "2.29.0",
    "eslint-plugin-jsdoc": "46.8.2",
    "eslint-plugin-prefer-arrow": "1.2.3",
    "install": "^0.13.0",
    "jasmine-core": "~5.1.1",
    "jasmine-spec-reporter": "~7.0.0",
    "karma": "~6.4.2",
    "karma-chrome-launcher": "~3.2.0",
    "karma-coverage": "~2.2.1",
    "karma-coverage-istanbul-reporter": "~3.0.3",
    "karma-jasmine": "~5.1.0",
    "karma-jasmine-html-reporter": "^2.1.0",
    "npm": "^10.2.3",
    "protractor": "~7.0.0",
    "ts-node": "~10.9.1",
    "typescript": "~5.3.3"
  },
  "description": "An Ionic project"
}

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "downlevelIteration": true,
    "experimentalDecorators": true,
    "moduleResolution": "node",
    "importHelpers": true,
    "target": "ES2022",
    "module": "es2020",
    "lib": [
      "es2018",
      "dom"
    ],
    "useDefineForClassFields": false,
    "allowSyntheticDefaultImports": true
  },
  "angularCompilerOptions": {
    "enableI18nLegacyMessageIdFormat": false,
    "strictInjectionParameters": true,
    "strictInputAccessModifiers": true,
    "strictTemplates": true
  }
}

Proposed Solution

Idk

Alternatives Considered

/

Additional Information

No response

mgasniernationex commented 1 week ago

Problem solved. I use the package in frontend app, bug it's server side package