@@ -7,7 +7,6 @@ import { promisify } from 'util'
7
7
8
8
import { HandlerEvent , HandlerResponse } from '@netlify/functions'
9
9
import { http , https } from 'follow-redirects'
10
- import { readJSON } from 'fs-extra'
11
10
import NextNodeServer from 'next/dist/server/next-server'
12
11
import { satisfies } from 'semver'
13
12
@@ -284,16 +283,17 @@ export const resolveModuleRoot = (moduleName) => {
284
283
}
285
284
}
286
285
// Had to copy nextPluginVersion logic from functionsMetaData for it to work within server.ts and getHandler.ts
287
- const nextPluginVersion = async ( module : string ) => {
288
- const moduleRoot = resolveModuleRoot ( module )
286
+ const nextPluginVersion = async ( ) => {
287
+ const moduleRoot = resolveModuleRoot ( 'next' )
289
288
if ( ! existsSync ( moduleRoot ) ) {
290
289
return
291
290
}
292
- const packagePlugin = await readJSON ( join ( moduleRoot , 'package.json' ) )
291
+ const packagePath = join ( moduleRoot , 'package.json' )
292
+ const packagePlugin = await fs . promises . readFile ( packagePath , 'utf-8' ) . then ( ( contents ) => JSON . parse ( contents ) )
293
293
return packagePlugin ?. version
294
294
}
295
295
296
- export const nextVersionNum = async ( ) => satisfies ( await nextPluginVersion ( 'next' ) , '13.3.3 - 13.4.9' )
296
+ export const nextVersionNum = async ( ) => satisfies ( await nextPluginVersion ( ) , '13.3.3 - 13.4.9' )
297
297
298
298
export const getMatchedRoute = (
299
299
paths : string ,
0 commit comments