Turfjs / turf

A modular geospatial engine written in JavaScript and TypeScript
https://turfjs.org/
MIT License
9.19k stars 934 forks source link

Module '"@turf/turf"' has no exported member 'transformScale'. #2533

Closed skhaz closed 9 months ago

skhaz commented 10 months ago

I'm having a bit of difficulty using this Turf module, others like polygon work perfectly.

I've tried in various ways and they all say the module doesn't exist. I deleted the node_modules and package-lock.json and still couldn't use it.

What am I doing wrong?

{
  "@turf/transform-scale": "^6.5.0",
  "@turf/turf": "^6.5.0",
}
import { transformScale } from '@turf/turf'

No.

import { transformScale as turfTransformScale } from '@turf/turf'

No.

import turf from '@turf/turf'

No.

Project is a Next.js based (default typescript template).

My package.json:

{
  "name": "walk-dashboard",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "@aws-sdk/client-s3": "^3.445.0",
    "@googlemaps/markerclusterer": "^2.5.1",
    "@googlemaps/react-wrapper": "^1.1.35",
    "@turf/circle": "^6.5.0",
    "@turf/transform-scale": "^6.5.0",
    "@turf/turf": "^6.5.0",
    "@upstash/redis": "^1.25.0",
    "google-map-react": "^2.2.1",
    "mapbox-gl": "^2.15.0",
    "next": "^14.0.1",
    "react": "^18",
    "react-dom": "^18",
    "react-map-gl": "^7.1.6"
  },
  "devDependencies": {
    "@types/google-map-react": "^2.1.10",
    "@types/google.maps": "^3.54.7",
    "@types/googlemaps": "^3.43.3",
    "@types/mapbox-gl": "^2.7.18",
    "@types/node": "^20.9.0",
    "@types/react": "^18.2.37",
    "@types/react-dom": "^18.2.15",
    "@types/turf": "^3.5.32",
    "eslint": "^8.53.0",
    "eslint-config-next": "^14.0.1",
    "typescript": "^5"
  }
}

My tsconfig.ts:

{
  "compilerOptions": {
    "target": "es5",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "bundler",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve",
    "incremental": true,
    "plugins": [
      {
        "name": "next"
      }
    ],
    "paths": {
      "~/*": ["./src/*"]
    }
  },
  "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
  "exclude": ["node_modules"]
}
twelch commented 10 months ago

Can you try import * as turf from '@turf/turf' documented here - https://turfjs.org/getting-started.

skhaz commented 10 months ago

@twelch, same problem

Property 'transformScale' does not exist on type 'TurfStatic'.

It's strange that it was working, I hadn't changed anything. On the other hand, Polygon is working fine.

twelch commented 10 months ago

Oh, I see the others are working for you. There were some missing exports in the past. Can you try the latest 7.x alpha release on npm and see if it's resolved?

skhaz commented 9 months ago

@twelch, the alpha release worked fine. Thank you.

twelch commented 9 months ago

Excellent, please feel free to report any new issue with 7.x while it stabilizes. Closing this one.