NextJs 报 SyntaxError: Cannot use import statement outside a module 第三方依赖不能导入问题
解决方案:
1,Next.JS13.1+,
可以使用next.config.js
中的属性transpilePackages
const nextConfig = { transpilePackages: ['the-npm-package'], // 第三方的依赖 }; module.exports = nextConfig;
2,next-transpile-modules
一个NPM模块,它允许您指定要传输的模块。
// next.config.js const withTM = require('next-transpile-modules')(['somemodule', 'and-another']); // pass the modules you would like to see transpiled module.exports = withTM(withLess({ ... // your custom next config }));
- SyntaxError statement 错误 outside Nextjssyntaxerror statement错误outside syntaxerror statement outside cannot statement错误invalid方法 skip-grant-tables账户statement错误 bindingexception statement错误invalid nextjs outside runtimeerror application working outside next-auth nextjs next auth dita directory the outside