Skip to content

Commit

Permalink
Do not have the required package error fix (#28662)
Browse files Browse the repository at this point in the history
The following error occurred 
when I created a project with the typecript template of createp-next-app 
and did the 'next build'.

```shell
It looks like you're trying to use TypeScript but do not have the required package(s) installed.

Please install @types/node by running:

        yarn add --dev @types/node

If you are not trying to use TypeScript, please remove the tsconfig.json file from your package root (and any TypeScript files in your pages directory).
```

This issue was resolved by adding @types/node.
So I added @types/node to the devDependencies of the create-next-app typecript template.
  • Loading branch information
eungyeole authored Sep 1, 2021
1 parent 501bfe6 commit c1dbc12
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/create-next-app/create-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ export async function createApp({
* TypeScript projects will have type definitions and other devDependencies.
*/
if (typescript) {
devDependencies.push('typescript', '@types/react')
devDependencies.push('typescript', '@types/react', '@types/node')
}
/**
* Install package.json dependencies if they exist.
Expand Down
1 change: 1 addition & 0 deletions test/integration/create-next-app/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ describe('create next app', () => {
'react-dom',
])
expect(Object.keys(pkgJSON.devDependencies)).toEqual([
'@types/node',
'@types/react',
'eslint',
'eslint-config-next',
Expand Down

1 comment on commit c1dbc12

@Jeric1223
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome

Please sign in to comment.