I am configuring a monorepo using yarn berry workspace.
So I created the next.js 13.4 project in the services folder (yarn create next-app) Next project creation has been completed.
And I entered the type check command to check the type of the project, but the following error occurred.
error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
12 images: `${process.env.NEXT_PUBLIC_STATIC_LINK}/web/resources/image/Link_bi.png`,
~~~~~~~
The error message is that the type cannot be found.
After searching, I added types:['node'] to my tsconfig.json
.
Again I got the following error:
Cannot find type definition file for 'node'.
The file is in the program because:
Entry point of type library 'node' specified in compilerOptions
tsconfig.json:12:15
12 "types": ["node"],
I'm guessing that the types module can't be found because I'm using the yarn berry workspace, but I don't know how to solve it.
I would appreciate your help.
tsconfig is being used by extending tsconfig.base.json from the root.
//tsconfig.base.json
{
"compilerOptions": {
"target": "es6",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": false,
"strict": true,
"forceConsistentCasingInFileNames": true,
"incremental": true,
"esModuleInterop": true,
"module": "commonjs",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true
}
}
// tsconfig.json of the project in question
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"baseUrl": "./src",
"target": "esnext",
"lib": ["dom", "dom.iterable", "esnext"],
"module": "esnext",
"jsx": "preserve",
"incremental": true,
"noEmit": true,
"types": ["node"],
"plugins": [
{
"name": "next"
}
]
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts", "**/*.mts", "**/*.json", "global.d.ts"],
"exclude": ["**/node_modules", "**/.*/"]
}
The following is package.json of the project in question.
{
...
"dependencies": {
"next": "13.4.19",
"react": "18.2.0",
"typescript": "5.2.2",
...
},
"devDependencies": {
"@types/node": "20.5.7",
"@types/react": "18.2.21",
"@types/react-dom": "18.2.7"
}
}