Closed JJ-udith closed 1 year ago
Fixed by adding 'next-transpile-modules' package to the project and in next.config.js:
/** @type {import('next').NextConfig} */
const withTM = require('next-transpile-modules')(['react-cytoscapejs']);
const nextConfig = {
reactStrictMode: true,
}
module.exports = withTM(nextConfig)
All features of next-transpile-modules are now natively built-in Next.js 13.1. No need to install next-transpile-modules anymore.
Adding transpilePackages: ["react-cytoscapejs"]
to next.config.js fixed the issue for me.
const config = {
reactStrictMode: true,
transpilePackages: ["react-cytoscapejs"],
};
https://nextjs.org/blog/next-13-1#built-in-module-transpilation-stable
Hello!
I tried to import CytoscapeComponent from "react-cytoscapejs" and get the follwoing error:
SyntaxError: Cannot use import statement outside a module
pointing to Object.react-cytoscapejs.If i manually add
"type": "module"
in the package.json of node_module react-cytoscapejs the error is gone. Now my problem is, that it works locally but deployment (vercel) leads to the same error.I may have discovered a similar error here with an answer from nextjs.
If i missed something here, please let me know if i can fix it somehow. Thank you and best regards
Graph.js:
Error: