Skip to content
This repository has been archived by the owner on Jan 26, 2019. It is now read-only.

Duplicate identifier 'URL'. #314

Closed
onlydave opened this issue Apr 26, 2018 · 15 comments
Closed

Duplicate identifier 'URL'. #314

onlydave opened this issue Apr 26, 2018 · 15 comments

Comments

@onlydave
Copy link

Failed to compile.

/apps/my-app/node_modules/@types/node/index.d.ts
(2381,15): Duplicate identifier 'URL'.

Environment

react-scripts-ts@2.15.1
npm -v 6.0.0 (tried @4 too)
node -v v8.11.1

create-react-app my-app --scripts-version=react-scripts-ts
cd my-app
npm start

Then got the error above

├── @types/jest@22.2.3
├── @types/node@10.0.0
├─┬ @types/react@16.3.12
│ └── csstype@2.4.1
├─┬ @types/react-dom@16.0.5
│ ├── @types/node@10.0.0 deduped
│ └── @types/react@16.3.12 deduped
@onlydave
Copy link
Author

onlydave commented Apr 26, 2018

Changing @types/node to version ^7.0.21 works. I'll do some trial and error to see if a more recent version works but might not be safe to let create app use the latest version

├── @types/jest@22.2.3
├── @types/node@7.0.61
├─┬ @types/react@16.3.12
│ └── csstype@2.4.1
├─┬ @types/react-dom@16.0.5
│ ├── @types/node@7.0.61 deduped
│ └── @types/react@16.3.12 deduped

EDIT: "@types/node": "^9.6.7" works 👍 🎉

├── @types/jest@22.2.3
├── @types/node@9.6.7
├─┬ @types/react@16.3.12
│ └── csstype@2.4.1
├─┬ @types/react-dom@16.0.5
│ ├── @types/node@9.6.7 deduped
│ └── @types/react@16.3.12 deduped

@ajgassner
Copy link

Same here. Windows 10, node v 10.0.0, npm 4.6.1

@azu
Copy link

azu commented Apr 26, 2018

@webstar1208
Copy link

Great Thanks. It works on V9.6.7.
But I have some questions.
I just searched Node previous version but not found 9.6.7.
What 's happened?

@Guria
Copy link

Guria commented Apr 27, 2018

Node JS 10.0 according to release notes introduces URL as new global

@Guria
Copy link

Guria commented Apr 27, 2018

So, now it conflicts with typescript lib.d.ts files. And this issue completely unrelated to current repo.
I would recommend to try using typeRoots setting in tsconfig and list only specific node_modules/@types/... needed for you project

@dereke55
Copy link

Probably a noob question/issue here, but is there a workaround in the meantime? Attempting to downgrade to @types/node@9.6.7 as suggested didn't seem to work:

$ npx create-react-app test-app  --scripts-version=react-scripts-ts
$ cd test-app
$ npm i @types/node@9.6.7
$ yarn start

output:

yarn run v1.6.0
$ react-scripts-ts start
/bin/sh: react-scripts-ts: command not found
error Command failed with exit code 127.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@zeljkoantich
Copy link

zeljkoantich commented Apr 28, 2018

@dereke55 you must target devDependencies with the "-D" flag:

npm remove -D @types/node  
npm i -D @types/node@9.6.7

@aditya-goyal-github
Copy link

Thanks @GoodDay2You , it works for me, all duplicate errors gone.

@yajuve
Copy link

yajuve commented Apr 29, 2018

I updated version to
npm i @types/node@9.6.7
and it works

@HuangHongRui
Copy link

Thanks..man
It Works for me..

npm i @types/node@9.6.7

@onlydave
Copy link
Author

onlydave commented Apr 30, 2018

Depends on your version of npm maybe it might not downgrade if you've already got 10.0.0 installed.

The safest thing to do is probably to edit package.json and change @types/node there.
Then rm -rf node_modules and then npm i

@dereke55
Copy link

Thanks again @GoodDay2You , worked like a charm

@DorianGrey
Copy link
Collaborator

FYI:
I've added a commit to pin the @types/node for the moment (though this is not yet released).
10b727f

However, this might no longer be required regarding this comment:
DefinitelyTyped/DefinitelyTyped#25356 (comment)
The issue with @types/node should be fixed with version 10.0.1. Could you give this version a try (just manually update it) ?

@wmonk
Copy link
Owner

wmonk commented May 10, 2018

I have just tested a fresh install of react-scripts-ts and it works fine installing @types/node@10.0.1 so am going to close. Please reopen if there is still an issue. Thanks all for helping!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests