首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >NextJS + Typescript构建失败,错误为@auth0/nextjs-auth0

NextJS + Typescript构建失败,错误为@auth0/nextjs-auth0
EN

Stack Overflow用户
提问于 2021-06-14 17:58:28
回答 4查看 178关注 0票数 0

我正在为NextJS使用Typescript,但我无法构建应用程序,因为它在auth0/nextjs-auth0中有一些问题

这就是问题所在。如果我安装了它,它将不断检查auth0/nextjs-auth0包中的问题。

下面是错误https://imgur.com/a/y7ft7Dq

这是我的tsconfig.json

代码语言:javascript
复制
    {
  "compilerOptions": {
    "target": "esnext",
    "module": "esnext",
    "lib": [
      "es6",
      "es7",
      "esnext",
      "dom"
    ],
    "allowJs": true, /* Allow javascript files to be compiled. */// "checkJs": true,                       /* Report errors in .js files. */
    "jsx": "preserve",                  /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
    "removeComments": false,
    "strict": true, /* Enable all strict type-checking options. */
    "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
    "strictNullChecks": true, /* Enable strict null checks. */
    "strictFunctionTypes": true, /* Enable strict checking of function types. */
    "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
    "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
    "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. *//* Additional Checks */
    "noUnusedLocals": true, /* Report errors on unused locals. */
    "noUnusedParameters": true, /* Report errors on unused parameters. */
    "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
    "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. *//* Module Resolution Options */
    "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
    "baseUrl": ".",                    /* Type declaration files to be included in compilation. */
    "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
    "esModuleInterop": true,                 /* Specify the location where debugger should locate map files instead of generated locations. */
    "inlineSourceMap": true,
    "inlineSources": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,
    "noEmit": true,
    "resolveJsonModule": true,
    "isolatedModules": true,
    "declaration": true,
    "declarationDir": "./node_modules/@auth0/nextjs-auth0/src/auth0-session",
    "declarationMap": true
  },
  "include": [
    "pages"
  ],
  "exclude": [
    "node_modules"
  ]
}
EN

回答 4

Stack Overflow用户

发布于 2021-06-23 19:46:04

运行以下命令,尝试错误消息所说的内容:

代码语言:javascript
复制
npm i --save-dev @types/url-join

如果不起作用,请尝试删除node_modules,然后运行npm installyarn

票数 0
EN

Stack Overflow用户

发布于 2021-08-09 09:06:18

我建议你看看official example。我在auth0 embed上也遇到过类似的问题。不要忘记,您需要将<Component>嵌入到app.js中,才能使auth0在页面上工作+使用withAuthRequired

代码语言:javascript
复制
import { UserProvider } from '@auth0/nextjs-auth0';

export default function App({ Component, pageProps }) {
  const { user } = pageProps;
  return (
      <UserProvider user={user}>
        <Component {...pageProps} />
      </UserProvider>
  );
}
票数 0
EN

Stack Overflow用户

发布于 2021-08-18 17:51:02

检查"tsconfig.json“文件中的编译选项"exclude”。如果它不存在,只需添加它并排除"node_modules“即可。

代码语言:javascript
复制
// tsconfig.json
{
  "compilerOptions": {
  ...
  "exclude": [
    "node_modules", 
  ]
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67968252

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档