错误:当目标不是服务器时,无法导出。在部署者期间使用下一个js和zeit-NOW

时间:2019-04-19 19:37:35

标签: reactjs next.js zeit-now

我正在使用React应用程序,我正在使用下一个js进行表达,我现在选择zeit来实现无服务,但是当我部署此面临的错误时错误:未构建无服务器页面

next.config.js

const configuration = withTypescript(
    withLess({,
     target: process.env.NODE_ENV === "development" ? "server" : "serverless",
      cssModules: true,
      lessLoaderOptions: {
        javascriptEnabled: true,
        modifyVars: themeVariables // make your antd custom effective
      },

      exportPathMap: async function(defaultPathMap) {
        return {
          "/": { page: "/index" },
        };
      },
      webpack: config => {
        config.plugins = config.plugins || [];
        config.plugins = [
          ...config.plugins,

          // Read the .env file
          new Dotenv({
            path: path.join(__dirname, "../.env"),
            systemvars: true
          })
        ];

        return config;
      },

    })
);

module.exports = configuration;

使用下一个版本:“ @ types / next”:“ ^ 8.0.0”,

now.json

{
  "version": 2,
  "name": "web",
  "builds": [
    { "src": "package.json", "use": "@now/next" }
  ],

}

内部包json

 "scripts": {
    "dev": "next src",
    "build": "next build src",
    "start": "next run build && next start src",
    "export": "npm run build && next export src -o ./out",
    "now-build": "next build src","
  },

立即Zeit 日志中获取错误

preparing lambda files...
2019-04-19T17:24:04.955Z  Error: No serverless pages were built. https://err.sh/zeit/now-builders/now-next-no-serverless-pages-built
                              at Object.exports.build (/tmp/utils/build-module/node_modules/@now/next/index.js:305:13)
                              at <anonymous>

请在这里帮助我解决。 谢谢。

0 个答案:

没有答案