我正在为NextJS使用Typescript,但我无法构建应用程序,因为它在auth0/nextjs-auth0中有一些问题
这就是问题所在。如果我安装了它,它将不断检查auth0/nextjs-auth0包中的问题。
下面是错误https://imgur.com/a/y7ft7Dq
这是我的tsconfig.json
{
"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"
]
}发布于 2021-06-23 19:46:04
运行以下命令,尝试错误消息所说的内容:
npm i --save-dev @types/url-join如果不起作用,请尝试删除node_modules,然后运行npm install或yarn
发布于 2021-08-09 09:06:18
我建议你看看official example。我在auth0 embed上也遇到过类似的问题。不要忘记,您需要将<Component>嵌入到app.js中,才能使auth0在页面上工作+使用withAuthRequired
import { UserProvider } from '@auth0/nextjs-auth0';
export default function App({ Component, pageProps }) {
const { user } = pageProps;
return (
<UserProvider user={user}>
<Component {...pageProps} />
</UserProvider>
);
}发布于 2021-08-18 17:51:02
检查"tsconfig.json“文件中的编译选项"exclude”。如果它不存在,只需添加它并排除"node_modules“即可。
// tsconfig.json
{
"compilerOptions": {
...
"exclude": [
"node_modules",
]
}https://stackoverflow.com/questions/67968252
复制相似问题