Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot init shadcn in next application #1525

Closed
hyper-dot opened this issue Sep 14, 2023 · 8 comments
Closed

Cannot init shadcn in next application #1525

hyper-dot opened this issue Sep 14, 2023 · 8 comments
Labels

Comments

@hyper-dot
Copy link

hyper-dot commented Sep 14, 2023

My whole terminal :

linux@linux ~/nextshadcn $ npx create-next-app@latest ./
✔ Would you like to use TypeScript?  YES
✔ Would you like to use ESLint? …  NO
✔ Would you like to use Tailwind CSS? …  YES
✔ Would you like to use `src/` directory? … YES
✔ Would you like to use App Router? (recommended) … YES
✔ Would you like to customize the default import alias? … YES
✔ What import alias would you like configured? … @/*
Creating a new Next.js app in /home/linux/nextshadcn.

Using npm.

Initializing project with template: app-tw


Installing dependencies:
- react
- react-dom
- next
- typescript
- @types/react
- @types/node
- @types/react-dom
- tailwindcss
- postcss
- autoprefixer


added 118 packages, and audited 119 packages in 17s

21 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
Initialized a git repository.

Success! Created nextshadcn at /home/linux/nextshadcn

linux@linux ~/nextshadcn (main) $ npx shadcn-ui@latest init
/home/linux/.npm/_npx/125ee17d583c4e03/node_modules/@babel/core/lib/index.js:7
Object.defineProperty(exports, "File", {
       ^

TypeError: Cannot redefine property: File
    at Function.defineProperty (<anonymous>)
    at Object.<anonymous> (/home/linux/.npm/_npx/125ee17d583c4e03/node_modules/@babel/core/lib/index.js:7:8)
    at Module._compile (node:internal/modules/cjs/loader:1241:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
    at Module.load (node:internal/modules/cjs/loader:1091:32)
    at Module._load (node:internal/modules/cjs/loader:938:12)
    at Module.require (node:internal/modules/cjs/loader:1115:19)
    at require (node:internal/modules/helpers:130:18)
    at Object.<anonymous> (/home/linux/.npm/_npx/125ee17d583c4e03/node_modules/@babel/core/lib/config/helpers/config-api.js:16:9)
    at Module._compile (node:internal/modules/cjs/loader:1241:14)

Node.js v20.6.0
@hyper-dot hyper-dot changed the title Cannot redefine property: File while adding new component npx shadcn-ui@latest add tabs Cannot init shadcn in next application Sep 14, 2023
@brunocroh
Copy link

I found this issue on babel repo babel/babel#15927

Try to remove your babel from global packages and run shadcn init command again to install a newer version from babel.
I tried here on node 20.6.1, and this is working well

@hyper-dot hyper-dot reopened this Sep 14, 2023
@hyper-dot
Copy link
Author

@brunocroh It worked. Thank you 🙇

@Jace996
Copy link

Jace996 commented Sep 17, 2023

@hyper-dot Hi, i faced same issue and tried to remove @babel in node_module but still the same. May I know how you remove the @babel/core?

@brunocroh
Copy link

@hyper-dot Hi, i faced same issue and tried to remove @babel in node_module but still the same. May I know how you remove the @babel/core?

Did you trying to update your node version to 20.6.1?

@hyper-dot
Copy link
Author

hyper-dot commented Sep 18, 2023

@Jace996 I am using linux and I removed it from $HOME/.npm.

In the error you can see path of your babel like in mine :

/home/linux/.npm/_npx/125ee17d583c4e03/node_modules/@babel/core/lib/index.js:7

Hope this helps. Or you can paste your logs.

@Obsidian-AI
Copy link

I removed all of babel as well, yet it still doesn't work. Here are my logs which was after i deleted @babel:
npx shadcn-ui@latest init

Need to install the following packages:
shadcn-ui@0.4.1
Ok to proceed? (y) y
/Users/karthiknadimpally/.npm/_npx/125ee17d583c4e03/node_modules/@babel/core/lib/index.js:7
Object.defineProperty(exports, "File", {
^

TypeError: Cannot redefine property: File
at Function.defineProperty ()
at Object. (/Users/karthiknadimpally/.npm/_npx/125ee17d583c4e03/node_modules/@babel/core/lib/index.js:7:8)
at Module._compile (node:internal/modules/cjs/loader:1241:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
at Module.load (node:internal/modules/cjs/loader:1091:32)
at Module._load (node:internal/modules/cjs/loader:938:12)
at Module.require (node:internal/modules/cjs/loader:1115:19)
at require (node:internal/modules/helpers:130:18)
at Object. (/Users/karthiknadimpally/.npm/_npx/125ee17d583c4e03/node_modules/@babel/core/lib/config/helpers/config-api.js:16:14)
at Module._compile (node:internal/modules/cjs/loader:1241:14)

Node.js v20.6.0

@brunocroh
Copy link

I removed all of babel as well, yet it still doesn't work. Here are my logs which was after i deleted @babel:

npx shadcn-ui@latest init

Need to install the following packages:

shadcn-ui@0.4.1

Ok to proceed? (y) y

/Users/karthiknadimpally/.npm/_npx/125ee17d583c4e03/node_modules/@babel/core/lib/index.js:7

Object.defineProperty(exports, "File", {

   ^

TypeError: Cannot redefine property: File

at Function.defineProperty (<anonymous>)

at Object.<anonymous> (/Users/karthiknadimpally/.npm/_npx/125ee17d583c4e03/node_modules/@babel/core/lib/index.js:7:8)

at Module._compile (node:internal/modules/cjs/loader:1241:14)

at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)

at Module.load (node:internal/modules/cjs/loader:1091:32)

at Module._load (node:internal/modules/cjs/loader:938:12)

at Module.require (node:internal/modules/cjs/loader:1115:19)

at require (node:internal/modules/helpers:130:18)

at Object.<anonymous> (/Users/karthiknadimpally/.npm/_npx/125ee17d583c4e03/node_modules/@babel/core/lib/config/helpers/config-api.js:16:14)

at Module._compile (node:internal/modules/cjs/loader:1241:14)

Node.js v20.6.0

Try update node to v20.6.1

@shadcn shadcn added the Stale label Feb 14, 2024
@shadcn
Copy link
Collaborator

shadcn commented Feb 27, 2024

This issue has been automatically closed because it received no activity for a while. If you think it was closed by accident, please leave a comment. Thank you.

@shadcn shadcn closed this as completed Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants