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 }));
标签:use,SyntaxError,module,next,outside,Cannot From: https://www.cnblogs.com/UnfetteredMan/p/17930923.html