jeffijoe / typesync

Install missing TypeScript typings for dependencies in your package.json.
MIT License
1.53k stars 22 forks source link

data.map is not a function #48

Closed linonetwo closed 4 years ago

linonetwo commented 4 years ago
% npx typesync       
»  TypeSync v0.6.1
✖  data.map is not a function
Stack:
TypeError: data.map is not a function
    at xxx/node_modules/typesync/lib/type-definition-source.js:59:52
    at step (xxx/node_modules/typesync/lib/type-definition-source.js:32:23)
    at Object.next (xxx/node_modules/typesync/lib/type-definition-source.js:13:53)
    at fulfilled (xxx/node_modules/typesync/lib/type-definition-source.js:4:58)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)

And my package json is

{
  "name": "zazu",
  "version": "0.6.0",
  "description": "A cross platform productivity application.",
  "scripts": {
    "prerelease": "npm install",
    "start": "cross-env NODE_ENV=development electron ./app/index.js",
    "test": "cross-env NODE_ENV=test electron-mocha ./app/index.js --recursive test/app",
    "build": "npm run build:js && cross-env npDEBUG=electron-builder ELECTRON_BUILDER_ALLOW_UNRESOLVED_DEPENDENCIES=true electron-builder --x64",
    "docs:publish": "gulp ghpages",
    "cucumber": "cucumber-js --require-module @babel/register --format node_modules/cucumber-pretty",
    "build:archlinux": "npm run build:js && cross-env DEBUG=electron-builder ELECTRON_BUILDER_ALLOW_UNRESOLVED_DEPENDENCIES=true electron-builder --x64 --linux pacman",
    "release:win": "npm run build:js && cross-env DEBUG=electron-builder ELECTRON_BUILDER_ALLOW_UNRESOLVED_DEPENDENCIES=true electron-builder --x64 --win --publish onTag",
    "release:linux": "npm run build:js && cross-env DEBUG=electron-builder ELECTRON_BUILDER_ALLOW_UNRESOLVED_DEPENDENCIES=true electron-builder --x64 --linux --publish onTag",
    "release:osx": "npm run build:js && cross-env DEBUG=electron-builder ELECTRON_BUILDER_ALLOW_UNRESOLVED_DEPENDENCIES=true electron-builder --x64 --publish onTag",
    "build:js": "concurrently \"npm run build:main\" \"npm run build:renderer\" \"npm run build:debug\"",
    "build:main": "cross-env NODE_ENV=production webpack --config ./configs/webpack.config.main.production.babel.js --colors",
    "build:renderer": "cross-env NODE_ENV=production webpack --config ./configs/webpack.config.renderer.production.babel.js --colors",
    "build:debug": "cross-env NODE_ENV=production webpack --config ./configs/webpack.config.renderer.debug.production.babel.js --colors",
    "lint": "eslint . --ext .js,.ts,.tsx",
    "lint:fix": "eslint . --ext .js,.ts,.tsx --fix",
    "format": "prettier . --write",
    "postinstall": "concurrently \"electron-builder install-app-deps\" \"typesync\""
  },
  "main": "app/dist/main.production.js",
  "husky": {
    "hooks": {
      "pre-commit": "npm run lint && pretty-quick --staged",
      "pre-push": "npm run lint && npm test"
    }
  },
  "build": {
    "productName": "Zazu",
    "appId": "com.tinytacoteam.zazu",
    "npmRebuild": false,
    "files": [
      "app",
      "package.json"
    ],
    "publish": [
      "github"
    ],
    "win": {
      "target": [
        "nsis"
      ],
      "icon": "resources/windows/icon.ico"
    },
    "nsis": {
      "oneClick": true,
      "installerHeaderIcon": "resources/windows/setup-icon.ico"
    },
    "linux": {
      "target": [
        "deb"
      ]
    },
    "mac": {
      "target": [
        "dmg"
      ],
      "icon": "resources/osx/icon.icns",
      "category": "public.app-category.productivity"
    },
    "dmg": {
      "icon": "resources/osx/dmg-icon.icns",
      "background": "resources/osx/dmg-background.png"
    },
    "directories": {
      "buildResources": "resources"
    }
  },
  "browserslist": "electron 5.0",
  "email": "zazu-app@googlegroups.com",
  "author": "Tiny Taco Team <zazu-app@googlegroups.com>",
  "homepage": "http://zazuapp.org",
  "license": "MIT",
  "repository": {
    "type": "git",
    "url": "git+ssh://git@github.com/tinytacoteam/zazu.git"
  },
  "bugs": {
    "url": "https://github.com/tinytacoteam/zazu/issues"
  },
  "dependencies": {
    "auto-launch": "^5.0.5",
    "cuid": "^2.1.8",
    "decompress": "^4.2.1",
    "fs-jetpack": "^2.2.3",
    "interweave": "^12.5.0",
    "mkdirp": "^1.0.3",
    "mousetrap": "^1.6.5",
    "nestdb": "^2.0.0",
    "node-notifier": "^6.0.0",
    "npm": "^6.14.4",
    "promise-retry": "^1.1.1",
    "prop-types": "^15.7.2",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "relaxed-json": "^1.0.3",
    "request": "^2.88.2",
    "semver": "^7.1.3",
    "winston": "^3.2.1",
    "winston-daily-rotate-file": "^4.4.2",
    "winston-transport": "^4.3.0"
  },
  "devDependencies": {
    "@babel/core": "^7.9.0",
    "@babel/plugin-proposal-class-properties": "^7.8.3",
    "@babel/plugin-proposal-decorators": "^7.8.3",
    "@babel/plugin-proposal-export-default-from": "^7.8.3",
    "@babel/plugin-proposal-export-namespace-from": "^7.8.3",
    "@babel/plugin-proposal-function-sent": "^7.8.3",
    "@babel/plugin-proposal-json-strings": "^7.8.3",
    "@babel/plugin-proposal-nullish-coalescing-operator": "^7.8.3",
    "@babel/plugin-proposal-numeric-separator": "^7.8.3",
    "@babel/plugin-proposal-optional-chaining": "^7.9.0",
    "@babel/plugin-proposal-private-methods": "^7.8.3",
    "@babel/plugin-proposal-throw-expressions": "^7.8.3",
    "@babel/plugin-syntax-dynamic-import": "^7.8.3",
    "@babel/plugin-syntax-import-meta": "^7.8.3",
    "@babel/plugin-transform-react-constant-elements": "^7.9.0",
    "@babel/plugin-transform-react-inline-elements": "^7.9.0",
    "@babel/preset-env": "^7.9.0",
    "@babel/preset-react": "^7.9.4",
    "@babel/preset-typescript": "^7.9.0",
    "@babel/register": "^7.9.0",
    "@babel/runtime": "^7.9.2",
    "@typescript-eslint/eslint-plugin": "^2.26.0",
    "@typescript-eslint/parser": "^2.26.0",
    "asar": "^3.0.3",
    "babel-eslint": "^10.1.0",
    "babel-loader": "^8.1.0",
    "babel-plugin-array-last-index": "0.0.5",
    "babel-plugin-closure-elimination": "^1.3.0",
    "babel-plugin-dynamic-import-node-babel-7": "^2.0.7",
    "babel-plugin-macros": "^2.8.0",
    "chai": "^4.2.0",
    "cheerio": "^1.0.0-rc.3",
    "concurrently": "^5.1.0",
    "cross-env": "^7.0.2",
    "cucumber": "^6.0.5",
    "cucumber-pretty": "^6.0.0",
    "electron": "^5.0.4",
    "electron-builder": "^22.4.1",
    "electron-mocha": "^8.0.2",
    "eslint": "^6.8.0",
    "eslint-config-prettier": "^6.10.1",
    "eslint-config-standard": "^14.1.1",
    "eslint-plugin-babel": "^5.3.0",
    "eslint-plugin-html": "^6.0.0",
    "eslint-plugin-import": "^2.20.2",
    "eslint-plugin-node": "^11.1.0",
    "eslint-plugin-promise": "4.2.1",
    "eslint-plugin-react": "^7.19.0",
    "eslint-plugin-standard": "4.0.1",
    "eslint-plugin-unicorn": "^18.0.1",
    "gh-pages": "^2.2.0",
    "gulp": "^4.0.2",
    "gulp-util": "^3.0.8",
    "husky": "^4.2.3",
    "is-travis": "^2.0.0",
    "mini-css-extract-plugin": "^0.9.0",
    "optimize-css-assets-webpack-plugin": "^5.0.3",
    "prettier": "2.0.2",
    "pretty-quick": "^2.0.1",
    "q": "^1.5.1",
    "rona": "^1.0.2",
    "sinon": "^9.0.1",
    "sinon-chai": "^3.5.0",
    "spectron": "^5.0.0",
    "terser-webpack-plugin": "^2.3.5",
    "typescript": "^3.8.3",
    "typesync": "^0.6.1",
    "webpack": "^4.42.1",
    "webpack-bundle-analyzer": "^3.6.1",
    "webpack-cli": "^3.3.11",
    "webpack-merge": "^4.2.2"
  },
  "optionalDependencies": {
    "appdmg": "^0.6.0",
    "robotjs": "^0.6.0",
    "rcedit": "^2.1.1"
  }
}
jeffijoe commented 4 years ago

How many times have you tried, and how long was the window between each try? I am trying to figure out if this is a transient issue. I can't reproduce.

linonetwo commented 4 years ago

I tried three times, because it takes so long to complete (with error), and I tried with or without VPN. It didn't take much bandwidth, network usage never go higher than 100KB/s.

Maybe you can use something like promise-retry to retry failed ones? Catching such error and retry it?

jeffijoe commented 4 years ago

Is it possibly a firewall issue? I can't reproduce at all, I've never seen this happen.

linonetwo commented 4 years ago

Can you make it possible to use the global npm config?

% npm config get registry                       
https://registry.npm.taobao.org/

https://github.com/jeffijoe/typesync/blob/23f8a5cb842f0fcf42e839b329c2c103823ab368/src/npm-client.ts#L4

I have set npm config set registry xxxx.taobao.xxxx to speed it up, because it is pretty slow to access npm behind the firewall.

linonetwo commented 4 years ago
Screen Shot 2020-04-03 at 4 04 26 PM

I edit node_modules/typesync/lib/npm-client.js and it works fine...Actually the firewall problem.

jeffijoe commented 4 years ago

That's weird because the callstack says it fails in the type definition source, which is fetching the search index, and that does not talk to NPM at all.

jeffijoe commented 4 years ago

Adding a timeout in #59 and the ability to read the registry url from npm config was added in #57.