question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: defaultLoader is not a function

See original GitHub issue

Describe the bug

yarn build fails on the vue-ts template

Reproduction

Create a new project with the vue-ts template

yarn create @vitejs/app

Install dependencies

yarn

Build

yarn build

System Info

  • vite version: 2.0.0-beta.12
  • Operating System: Windows 10
  • Node version: v14.15.4
  • Package manager (npm/yarn/pnpm) and version: yarn 1.22.0

Logs (Optional if provided reproduction)

$ C:\projects\vite-test\node_modules\.bin\vite build --debug
failed to load config from /projects/vite-test/vite.config.ts
error during build:
TypeError: defaultLoader is not a function
    at Object.require.extensions.<computed> [as .ts] (C:\projects\vite-test\node_modules\vite\dist\node\chunks\dep-30d01443.js:46937:13)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at loadConfigFromBundledFile (C:\projects\vite-test\node_modules\vite\dist\node\chunks\dep-30d01443.js:46941:17)
    at loadConfigFromFile (C:\projects\vite-test\node_modules\vite\dist\node\chunks\dep-30d01443.js:46888:32)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async resolveConfig (C:\projects\vite-test\node_modules\vite\dist\node\chunks\dep-30d01443.js:46650:28)
    at async doBuild (C:\projects\vite-test\node_modules\vite\dist\node\chunks\dep-30d01443.js:39447:20)
error Command failed with exit code 1.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
yyx990803commented, Jan 12, 2021

Hmm, weird how the windows CI passed 🤔

2reactions
shashwatsinghcommented, Feb 17, 2021

I got the same error message on Windows 10 with vite 2.0, but with a slight change: my working directory is a symlink to a longer path.

I was not sure if this is a supported use-case, so please ignore if not.

Details: Actual directory: C:\Users\<user>Documents\js\viteapp Symlink: c:\work\viteapp (created using mklink /D c:\work C:\Users\<user>\Documents\js\)

Vite Version:

vite@^2.0.0:
  version "2.0.0"
  resolved "https://registry.yarnpkg.com/vite/-/vite-2.0.0.tgz#156f35eadaa7947629aa8a24eb23129b07116ee3"
  integrity sha512-rNli5g0DaQ6+btlRqkmaR06neWaJGApmt40gocqrYDNi2XoEXYQgKiHSWzMeUgc1Cdva2HduqazaE+RaKjBpdQ==
  dependencies:
    esbuild "^0.8.34"
    postcss "^8.2.1"
    resolve "^1.19.0"
    rollup "^2.38.5"
  optionalDependencies:
    fsevents "~2.3.1"

Steps (happens in Windows Command Prompt (cmd.exe) and Windows Terminal (wt.exe):

C:\work\viteapp>yarn dev
yarn run v1.22.5
warning package.json: No license field
$ vite
failed to load config from C:\work\viteapp\vite.config.ts
error when starting dev server:
TypeError: defaultLoader is not a function
    at Object.require.extensions.<computed> [as .ts] (C:\Users\SS\Documents\js\viteapp\node_modules\vite\dist\node\chunks\dep-9bcbff8e.js:48440:13)
    at Module.load (node:internal/modules/cjs/loader:973:32)
    at Function.Module._load (node:internal/modules/cjs/loader:813:14)
    at Module.require (node:internal/modules/cjs/loader:997:19)
    at require (node:internal/modules/cjs/helpers:92:18)
    at loadConfigFromBundledFile (C:\Users\SS\Documents\js\viteapp\node_modules\vite\dist\node\chunks\dep-9bcbff8e.js:48445:17)
    at loadConfigFromFile (C:\Users\SS\Documents\js\viteapp\node_modules\vite\dist\node\chunks\dep-9bcbff8e.js:48381:32)
    at processTicksAndRejections (node:internal/process/task_queues:94:5)
    at async resolveConfig (C:\Users\SS\Documents\js\viteapp\node_modules\vite\dist\node\chunks\dep-9bcbff8e.js:48007:28)
    at async createServer$2 (C:\Users\SS\Documents\js\viteapp\node_modules\vite\dist\node\chunks\dep-9bcbff8e.js:67828:20)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

It runs after I move into the actual directory:

C:\work\viteapp>cd C:\Users\SS\Documents\js\viteapp\

C:\Users\SS\Documents\js\viteapp>yarn dev
yarn run v1.22.5
warning package.json: No license field
$ vite
Pre-bundling dependencies:
  vue
(this will be run only when your dependencies or config have changed)

 ⚡ Vite dev server running at:

  > Network:  http://192.168.43.231:3000/
  > Local:    http://localhost:3000/
  > Network:  http://xxx.xx.xxx.xx:3000/

  ready in 2878ms.
Read more comments on GitHub >

github_iconTop Results From Across the Web

maplibre build-dev "TypeError: defaultLoader is not a function"
Getting the error below trying to build maplibre on my Windows box. Followed the CONTRIBUTING.md steps (node, windows-dev-tools, npm i, .
Read more >
cosmiconfig - npm
An object that maps extensions to the loader functions responsible for loading and parsing files with those extensions. Cosmiconfig exposes its ...
Read more >
typeerror: (0 , express_1.default) is not a function - You.com
I'm getting [TypeError: (0 , express_1.default) is not a function for my code. import express from "express"; const app = express (); //...
Read more >
Error: Image Optimization using Next.js default loader is not ...
[Solved]-Error: Image Optimization using Next.js default loader is not ... error in Next js with redux thunk TypeError: nextCallback is not a function...
Read more >
expose-loader - webpack
The require.resolve call is a Node.js function (unrelated to ... By default loader does not override the existing value in the global object,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found