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"]
}
Importing it like this should work: