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

npx vitest : error failed to load config from vite.config.ts #906

Closed
6 tasks done
wael-fadlallah opened this issue Mar 7, 2022 · 12 comments
Closed
6 tasks done

npx vitest : error failed to load config from vite.config.ts #906

wael-fadlallah opened this issue Mar 7, 2022 · 12 comments

Comments

@wael-fadlallah
Copy link
Contributor

Describe the bug

I have just added Vitest to my new Vite project, I didn't make any configuration or anything

Error:

npx vitest        
failed to load config from /Users/ridanayed/Desktop/repo/posts/ci-cd/vite.config.ts

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Error ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Error: 
You installed esbuild on another platform than the one you're currently using.
This won't work because esbuild is written with native code and needs to
install a platform-specific binary executable.

Specifically the "esbuild-darwin-arm64" package is present but this platform
needs the "esbuild-darwin-64" package instead. People often get into this
situation by installing esbuild on Windows or macOS and copying "node_modules"
into a Docker image that runs Linux, or by copying "node_modules" between
Windows and WSL environments.

If you are installing with npm, you can try not copying the "node_modules"
directory when you copy the files over, and running "npm ci" or "npm install"
on the destination platform after the copy. Or you could consider using yarn
instead which has built-in support for installing a package on multiple
platforms simultaneously.

If you are installing with yarn, you can try listing both this platform and the
other platform in your ".yarnrc.yml" file using the "supportedArchitectures"
feature: https://yarnpkg.com/configuration/yarnrc/#supportedArchitectures
Keep in mind that this means multiple copies of esbuild will be present.

Another alternative is to use the "esbuild-wasm" package instead, which works
the same way on all platforms. But it comes with a heavy performance cost and
can sometimes be 10x slower than the "esbuild" package, so you may also not
want to do that.

    at generateBinPath (/Users/ridanayed/Desktop/repo/posts/ci-cd/node_modules/esbuild/lib/main.js:1790:17)
    at esbuildCommandAndArgs (/Users/ridanayed/Desktop/repo/posts/ci-cd/node_modules/esbuild/lib/main.js:1874:31)
    at ensureServiceIsRunning (/Users/ridanayed/Desktop/repo/posts/ci-cd/node_modules/esbuild/lib/main.js:2036:25)
    at Object.build (/Users/ridanayed/Desktop/repo/posts/ci-cd/node_modules/esbuild/lib/main.js:1929:26)
    at bundleConfigFile (/Users/ridanayed/Desktop/repo/posts/ci-cd/node_modules/vite/dist/node/chunks/dep-9c153816.js:71364:34)
    at loadConfigFromFile (/Users/ridanayed/Desktop/repo/posts/ci-cd/node_modules/vite/dist/node/chunks/dep-9c153816.js:71341:35)
    at resolveConfig (/Users/ridanayed/Desktop/repo/posts/ci-cd/node_modules/vite/dist/node/chunks/dep-9c153816.js:70873:34)
    at createServer (/Users/ridanayed/Desktop/repo/posts/ci-cd/node_modules/vite/dist/node/chunks/dep-9c153816.js:56425:26)
    at createVitest (file:///Users/ridanayed/Desktop/repo/posts/ci-cd/node_modules/vitest/dist/chunk-vite-node-externalize.feaddbac.js:10839:24)
    at async startVitest (file:///Users/ridanayed/Desktop/repo/posts/ci-cd/node_modules/vitest/dist/chunk-vite-node-externalize.feaddbac.js:10924:15)

Package.json

{
  "name": "ci-cd",
  "private": true,
  "version": "0.0.0",
  "scripts": {
    "dev": "vite",
    "build": "tsc && vite build",
    "preview": "vite preview"
  },
  "dependencies": {
    "lodash": "^4.17.21",
    "react": "^17.0.2",
    "react-dom": "^17.0.2"
  },
  "devDependencies": {
    "@types/lodash": "^4.14.179",
    "@types/react": "^17.0.33",
    "@types/react-dom": "^17.0.10",
    "@vitejs/plugin-react": "^1.0.7",
    "autoprefixer": "^10.4.2",
    "postcss": "^8.4.7",
    "tailwindcss": "^3.0.23",
    "typescript": "^4.5.4",
    "vite": "^2.8.0",
    "vitest": "^0.6.0"
  }
}

Reproduction

My repo is public, here is the link https://github.com/wael-Fadlallah/blog-example-app

yarn  install 
npx vitest

System Info

System:
    OS: macOS 12.0.1
    CPU: (8) x64 Apple M1
    Memory: 44.39 MB / 8.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 17.3.1 - ~/node_modules/.bin/node
    Yarn: 1.22.17 - /opt/homebrew/bin/yarn
    npm: 8.3.1 - /opt/homebrew/bin/npm
ridanayed@Ridas-MBP ci-cd % ¬npx envinfo --system --npmPackages '{vitest,vite,@vitejs/*}' --binaries --browsers
zsh: command not found: ¬npx
ridanayed@Ridas-MBP ci-cd % npx envinfo --system --npmPackages '{vitest,vite,@vitejs/*}' --binaries --browsers

  System:
    OS: macOS 12.0.1
    CPU: (8) x64 Apple M1
    Memory: 55.09 MB / 8.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 17.3.1 - ~/node_modules/.bin/node
    Yarn: 1.22.17 - /opt/homebrew/bin/yarn
    npm: 8.3.1 - /opt/homebrew/bin/npm
    Watchman: 2022.01.31.00 - /opt/homebrew/bin/watchman
  Browsers:
    Chrome: 99.0.4844.51
    Firefox: 97.0.2
    Firefox Developer Edition: 98.0
    Safari: 15.1
  npmPackages:
    @vitejs/plugin-react: ^1.0.7 => 1.2.0 
    vite: ^2.8.0 => 2.8.6 
    vitest: ^0.6.0 => 0.6.0

Used Package Manager

yarn

Validations

@sheremet-va
Copy link
Member

sheremet-va commented Mar 8, 2022

Please, refer to evanw/esbuild#1819
esbuild is installed incorrectly

@wael-fadlallah
Copy link
Contributor Author

Nothing in that thread tells me how to fix it,
I have just test it it's working in windows

@sheremet-va
Copy link
Member

Your reproduction is working for me, if I add "test": "vitest" to scripts in package.json and run it.

@wael-fadlallah
Copy link
Contributor Author

I have added it, still same issue :(

@sheremet-va
Copy link
Member

The issue is with your pipeline, not with Vitest itself. I suggest you ask for help in our discord.

@wael-fadlallah
Copy link
Contributor Author

Will do, Thanks :)

@montaro
Copy link

montaro commented Jul 28, 2022

Hey @wael-fadlallah
Have you managed to get this working on Mac?

@wael-fadlallah
Copy link
Contributor Author

If I remember correctly I think I have solved it by deleting the node modules directory and switching to PNPM,

@montaro
Copy link

montaro commented Jul 28, 2022

Thanks for the swift answer. Actually, I get this When I'm trying to build a docker image

=> ERROR [build-stage 7/8] RUN npm run build                                                                    19.9s
------
 > [build-stage 7/8] RUN npm run build:
#15 2.690
#15 2.690 > xyz-ui@0.0.0 build /app
#15 2.690 > tsc && vite build
#15 2.690
#15 19.51 qemu: uncaught target signal 11 (Segmentation fault) - core dumped
#15 19.54 failed to load config from /app/vite.config.ts
#15 19.54 error during build:
#15 19.54 Error: The service was stopped: write EPIPE
#15 19.54     at /app/node_modules/esbuild/lib/main.js:1343:25
#15 19.54     at /app/node_modules/esbuild/lib/main.js:674:9
#15 19.54     at afterClose (/app/node_modules/esbuild/lib/main.js:652:7)
#15 19.54     at /app/node_modules/esbuild/lib/main.js:2052:11
#15 19.54     at onwriteError (internal/streams/writable.js:384:3)
#15 19.54     at processTicksAndRejections (internal/process/task_queues.js:84:21)
#15 19.59 npm ERR! code ELIFECYCLE
#15 19.59 npm ERR! errno 1
#15 19.60 npm ERR! xyz-ui@0.0.0 build: `tsc && vite build`
#15 19.60 npm ERR! Exit status 1

So node_modules are created from scratch, any hints? Thanks!

@wael-fadlallah
Copy link
Contributor Author

Oh sorry, I have no clue

@farhadjalali
Copy link

(A little bit late but) I added this dependency explicitly to my package.json and it fixed my problem:
"devDependencies": {
"esbuild-darwin-64": "^0.15.15"
}

@magicalTom
Copy link

可能是 nvm 设置的默认 node 版本不符合

@github-actions github-actions bot locked and limited conversation to collaborators Jun 7, 2023
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

5 participants