Cocos Creator 3.7.1 nav2d from node_modules is undefined

Hi all, I am trying to use nav2d - npm module,
but I am getting undefined of import:

import { NavMesh } from 'nav2d'; // Tried different ways...
import NavMesh from 'nav2d'; // Tried different ways...

console.log('My Nav Mesh:' + NavMesh);

image

1 Like

Hi, this is because nav2d uses the crypto built-in library, so there is no way to reference it directly.
You can use webpack to package the nav2d library as a plugin that can be used directly by the Creator editor and import it into your project.

Example
Creator3.7.1_nav2dUse.zip (35.0 KB)

1 Like