Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Next.js npm运行构建时出现错误:映像优化_Next.js_Nextjs Image - Fatal编程技术网

Next.js npm运行构建时出现错误:映像优化

Next.js npm运行构建时出现错误:映像优化,next.js,nextjs-image,Next.js,Nextjs Image,我不熟悉Next.js,我构建了一个简单的登录页面,并希望使用npm run build生成一个静态页面,我在package.json中将其设置为“build”:“Next build&&Next export”。 但我得到了这个错误: Error: Image Optimization using Next.js' default loader is not compatible with `next export`. Possible solutions: - Use `next

我不熟悉Next.js,我构建了一个简单的登录页面,并希望使用npm run build生成一个静态页面,我在package.json中将其设置为
“build”:“Next build&&Next export”
。 但我得到了这个错误:

Error: Image Optimization using Next.js' default loader is not compatible with `next export`.
  Possible solutions:
    - Use `next start` to run a server, which includes the Image Optimization API.
    - Use any provider which supports Image Optimization (like Vercel).
    - Configure a third-party loader in `next.config.js`.
    - Use the `loader` prop for `next/image`.
有人能帮我吗?我阅读了文档,在根目录中创建了next.config.js并粘贴了以下内容:

module.exports = {
  images: {
    loader: 'imgix',
    path: '/images/',
  },
}
我想我需要一个路径,但问题是我没有使用托管图像,我在公用文件夹中有一个图像文件夹

我知道这可能是个愚蠢的问题,但我被卡住了。

我在上托管了它们,并在next.config.js中写下了这篇文章

module.exports = { 
    images: { 
        domains: ['i.ibb.co'],
    },
} 
它成功了

用法:

<Image src="https://i.ibb.co/TMBV2KP/Akwagroup.jpg" 
       alt="ESMASA TRAVAUX"
       width={1050}
       height={500}
/>


您需要使用第三方云提供商来优化您的
下一个/image
图像,使用
下一个导出
——这将要求您在这样的云提供商上托管它们。明白了。我在上托管了它们,并在next.config.js`module.exports={images:{domains:['I.ibb.co'],},},}中编写了这篇文章,它成功了。非常感谢。