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

[vite] error while updating dependencies - Access is denied #207

Open
chapus opened this issue Sep 29, 2021 · 30 comments
Open

[vite] error while updating dependencies - Access is denied #207

chapus opened this issue Sep 29, 2021 · 30 comments
Labels
bug Something isn't working

Comments

@chapus
Copy link

chapus commented Sep 29, 2021

nuxt-vite: 0.2.4
nuxt: 2.15.8

Reproduction

npm run dev sometimes throw and error while compiling in dev mode.

Description

 ERROR  6:17:50 PM [vite] error while updating dependencies:                                                                                                       18:17:50
Error: Build failed with 1 error:
error: Failed to write to output file: open D:\git\myproject\node_modules\.cache\vite\client\vuetify.js: Access is denied.
    at failureErrorWithLog (D:\git\myproject\node_modules\esbuild\lib\main.js:1493:15)
    at runOnEndCallbacks (D:\git\myproject\node_modules\esbuild\lib\main.js:941:63)
    at buildResponseToResult (D:\git\myproject\node_modules\esbuild\lib\main.js:1149:7)
    at D:\git\myproject\node_modules\esbuild\lib\main.js:1258:14
    at D:\git\myproject\node_modules\esbuild\lib\main.js:629:9
    at handleIncomingPacket (D:\git\myproject\node_modules\esbuild\lib\main.js:726:9)
    at Socket.readFromStdout (D:\git\myproject\node_modules\esbuild\lib\main.js:596:7)
    at Socket.emit (events.js:375:28)
    at Socket.emit (domain.js:470:12)
    at addChunk (internal/streams/readable.js:290:12)
    at readableAddChunk (internal/streams/readable.js:265:9)
    at Socket.Readable.push (internal/streams/readable.js:204:10)
    at Pipe.onStreamRead (internal/stream_base_commons.js:188:23)

I need to close the browser window and run again npm run dev and sometimes the application runs ok throwing some errors like:

 ERROR  6:23:35 PM [vite] Internal server error: Failed to resolve import "./chunk-A5ICIBVI.js" from "node_modules\.cache\vite\client\chunk-PNIETXK5.js?v=c0ccd1a7". Does the file exist?
  Plugin: vite:import-analysis
  File: D:/git/project/node_modules/.cache/vite/client/chunk-PNIETXK5.js?v=c0ccd1a7
  2  |    __esm,
  3  |    __export
  4  |  } from "./chunk-A5ICIBVI.js";
     |          ^
  5  |
  6  |  // node_modules/vue/dist/vue.runtime.esm.js
      at formatError (D:\git\project\node_modules\vite\dist\node\chunks\dep-a8e01c9f.js:50383:46)
      at TransformContext.error (D:\git\project\node_modules\vite\dist\node\chunks\dep-a8e01c9f.js:50379:19)
      at normalizeUrl (D:\git\project\node_modules\vite\dist\node\chunks\dep-a8e01c9f.js:75377:26)
      at async TransformContext.transform (D:\git\project\node_modules\vite\dist\node\chunks\dep-a8e01c9f.js:75517:57)
      at async Object.transform (D:\git\project\node_modules\vite\dist\node\chunks\dep-a8e01c9f.js:50590:30)
      at async doTransform (D:\git\project\node_modules\vite\dist\node\chunks\dep-a8e01c9f.js:64911:29)
@chapus chapus added the bug Something isn't working label Sep 29, 2021
@chapus
Copy link
Author

chapus commented Sep 29, 2021

I found something... maybe it helps why is happening but not the resolution of the case.
When i left the browser window open i see in the console trying to connect to __vite_ping socket... and is looping, and when i hit npm run dev appears the error about Access is denied. If I close everything and run again it works (throwing the error:
[vite] Internal server error: Failed to resolve import "./chunk-XXXXXXXX.js" from "node_modules\.cache\vite\client\chunk-XXXXXX.js?v=f0f3a41b". Does the file exist? but the app starts.

image

@antfu
Copy link
Member

antfu commented Sep 30, 2021

Can you clean up the node_modules and try again with a clean install. If it still persists, please provide a minimal reproduction.

@chapus
Copy link
Author

chapus commented Sep 30, 2021

Deleted node_modes/ and package-lock.json after npm run dev when I browse the app this error appears:

 ERROR  1:44:44 AM [vite] Internal server error: Failed to resolve import "./chunk-A5ICIBVI.js" from "node_modules\.cache\vite\client\chunk-PNIETXK5.js?v=b9861b31". Does the file exist?
  Plugin: vite:import-analysis
  File: D:/git/project/node_modules/.cache/vite/client/chunk-PNIETXK5.js?v=b9861b31
  2  |    __esm,
  3  |    __export
  4  |  } from "./chunk-A5ICIBVI.js";
     |          ^
  5  |
  6  |  // node_modules/vue/dist/vue.runtime.esm.js
      at formatError (D:\git\project\node_modules\vite\dist\node\chunks\dep-a8e01c9f.js:50383:46)
      at TransformContext.error (D:\git\project\node_modules\vite\dist\node\chunks\dep-a8e01c9f.js:50379:19)
      at normalizeUrl (D:\git\project\node_modules\vite\dist\node\chunks\dep-a8e01c9f.js:75377:26)
      at async TransformContext.transform (D:\git\project\node_modules\vite\dist\node\chunks\dep-a8e01c9f.js:75517:57)
      at async Object.transform (D:\git\project\node_modules\vite\dist\node\chunks\dep-a8e01c9f.js:50590:30)
      at async doTransform (D:\git\project\node_modules\vite\dist\node\chunks\dep-a8e01c9f.js:64911:29)

After the error there is a hot reload and the app run ok.

I stopped node, then run again npm run dev and I get the error about Access is denied.

> error: Failed to write to output file: open D:\git\project\node_modules\.cache\vite\client\vue-apexcharts.js: Access is denied.

 > error: Failed to write to output file: open D:\git\project\node_modules\.cache\vite\client\chunk-E4I4RMZX.js: Access is denied.

 > error: Failed to write to output file: open D:\git\project\node_modules\.cache\vite\client\vue-feather-icons.js: Access is denied.

 > error: Failed to write to output file: open D:\git\project\node_modules\.cache\vite\client\vuesax.js: Access is denied.

 > error: Failed to write to output file: open D:\git\project\node_modules\.cache\vite\client\vuetify.js: Access is denied.


 ERROR  1:45:50 AM [vite] error while updating dependencies:                                                                                               01:45:50
Error: Build failed with 5 errors:
error: Failed to write to output file: open D:\git\project\node_modules\.cache\vite\client\vue-apexcharts.js: Access is denied.
error: Failed to write to output file: open D:\git\project\node_modules\.cache\vite\client\chunk-E4I4RMZX.js: Access is denied.
error: Failed to write to output file: open D:\git\project\node_modules\.cache\vite\client\vue-feather-icons.js: Access is denied.
error: Failed to write to output file: open D:\git\project\node_modules\.cache\vite\client\vuesax.js: Access is denied.
error: Failed to write to output file: open D:\git\project\node_modules\.cache\vite\client\vuetify.js: Access is denied.
    at failureErrorWithLog (D:\git\project\node_modules\esbuild\lib\main.js:1493:15)
    at D:\git\project\node_modules\esbuild\lib\main.js:1151:28
    at runOnEndCallbacks (D:\git\project\node_modules\esbuild\lib\main.js:941:63)
    at buildResponseToResult (D:\git\project\node_modules\esbuild\lib\main.js:1149:7)
    at D:\git\project\node_modules\esbuild\lib\main.js:1258:14
    at D:\git\project\node_modules\esbuild\lib\main.js:629:9
    at handleIncomingPacket (D:\git\project\node_modules\esbuild\lib\main.js:726:9)
    at Socket.readFromStdout (D:\git\project\node_modules\esbuild\lib\main.js:596:7)
    at Socket.emit (events.js:375:28)
    at Socket.emit (domain.js:470:12)
    at addChunk (internal/streams/readable.js:290:12)
    at readableAddChunk (internal/streams/readable.js:265:9)
    at Socket.Readable.push (internal/streams/readable.js:204:10)
    at Pipe.onStreamRead (internal/stream_base_commons.js:188:23)

In this case 5 errors about Access denied, if I stop and close everything and start again, 2 errors about Access denied...

It seems to be random when the app up right.

@hotrungnhan
Copy link

this only happen in 0.3.4 version . 0.2.4 dont have it.

@chapus
Copy link
Author

chapus commented Oct 6, 2021

Let me check downgrading the version and post the results. @hotrungnhan

@DenisLevy76
Copy link

same problem

@Congb19
Copy link

Congb19 commented Nov 10, 2021

same problem in vite but not use nuxt.
I guess maybe it's because of windows shell access?the problem doesn't appear in a same enviroment in Macos (the same project, the latest pnpm)
but when i use powershell as administrator, the problem still exist:

[vite] error while updating dependencies:
Error: Build failed with 1 error:
error: Failed to write to output file: open D:\repos\naive-ui\node_modules.vite@vicons_ionicons5.js: Access is denied.

@freedomdebug
Copy link

same problem
when i add an new npm packages
then the ui updating and got this error

error: Failed to write to output file: open node_modules.vite\ant-design-vue.js: Access is denied.

@jiqiangzhu
Copy link

same problem
when i add an new npm packages
then the ui updating and got this error

[vite] error while updating dependencies:
Error: Build failed with 1 error:
error: Failed to write to output file: open E:\WEB\Blog\blog-web-vite\node_modules.vite\element-plus.js: Access is denied.

@Zhaocl1997
Copy link

Yeah, the same error(just vite ,no nuxt). Yesterday when i run dev, it just break down suddenly.

> error: Failed to write to output file: open D:\projects\walnut\walnut-admin\walnut-admin-client\node_modules\.vite\naive-ui.js: Access is denied.

@LuEason
Copy link

LuEason commented Nov 18, 2021

Same problem when I using node version 14.15.0, but I switch node to version 16.13.0 this problem did not show up. I delete the 'node_modules/.vite' folder and switch node back to version 14.15.0, this problem show up again.

@Zhaocl1997
Copy link

Same problem when I using node version 14.15.0, but I switch node to version 16.13.0 this problem did not show up. I delete the 'node_modules/.vite' folder and switch node back to version 14.15.0, this problem show up again.

Oh, thank u. Node 16.13.0 is ok.

@Congb19
Copy link

Congb19 commented Nov 19, 2021

Same problem when I using node version 14.15.0, but I switch node to version 16.13.0 this problem did not show up. I delete the 'node_modules/.vite' folder and switch node back to version 14.15.0, this problem show up again.

Thank you! Node 16.13.0 works. I used Node 14.15.3 before.

@liangyuanzu
Copy link

Same problem when I using node version 14.15.0, but I switch node to version 16.13.0 this problem did not show up. I delete the 'node_modules/.vite' folder and switch node back to version 14.15.0, this problem show up again.

But my node version is 16.13.0 and still have this problem.
vite: ^2.7.6
Upgrade to the latest vite still the same error.
image

@yll521
Copy link

yll521 commented Jan 6, 2022

卸载node 重新安装

@liangyuanzu
Copy link

I found the problem in the last row. The reason was that regular expressions were used, as follows:

export const foo = (url: string) => {
  return /\?$/.test(url) ? true : false
}

When I extracted the regularity, it passed the compilation smoothly, as follows:

export const foo = (url: string) => {
  const reg = /\?$/
  return reg.test(url) ? true : false
}

I don’t know why this happens, can anyone help me answer it?

@ga676005
Copy link

ga676005 commented Jan 17, 2022

I upgrade vite from 2.6.14 to 2.7.12 and have this problem too. I have upgraded my node.js to 16.13.2.

When I downgrade vite to 2.6.14, it reloads a few times but the server can spin up.
image

Then I upgrade vite to 2.7.12, It seems that server can spin up but the page doesn't work.
image

Here is everything from my console
image

After closing the browser and npm run dev, those failed to load... don't appear in the terminal anymore but the page still failed to load correctly, and the errors in the console remain the same.

I'll just stay using vite: 2.6.14 which is a working version for me.
Just tried to provide some information here, sorry if this is unhelpful.

update

After deleting package-lock.json and node_modules and reinstall the packages with npm i, now I have vite: 2.7.12 working properly, although it still shows a bunch of Failed to load source map... at the first time of running npm run dev

@sRect
Copy link

sRect commented Jan 27, 2022

Same problem when I using node version 14.15.0, but I switch node to version 16.13.0 this problem did not show up. I delete the 'node_modules/.vite' folder and switch node back to version 14.15.0, this problem show up again.

Thanks! Use Node.js version 16.13.2 is ok.

@AK47-dadada
Copy link

Same problem when I using node version 14.15.0, but I switch node to version 16.13.0 this problem did not show up. I delete the 'node_modules/.vite' folder and switch node back to version 14.15.0, this problem show up again.

Thanks! Use Node.js version 16.13.2 is ok.

The same problem, but only when switching between dev and prod(dev to prod) .But my solution is different from yours, and I hope it helps.
First of all: there is no need to upgrade Nodejs to 16.x, my own version is 14.x
vite.config.js/ts has a configuration called cacheDir:
type: string
default: "node_modules/.vite"
Directory to save cache files. Files in this directory are pre-bundled deps or some other cache files generated by vite, which can improve the performance. You can use --force flag or manually delete the directory to regenerate the cache files. The value can be either an absolute file system path or a path relative to project root. Default to .vite when no package.json is detected.
The key word is --force,
Vite added caching to node_modules/. Vite to improve performance.
If you want to clear the cache, you need to add the --force directive to the startup command.
For example: NPM run vite --force, of course you can also configure your own directives in package.json:
{ "name": "test-production", "version": "2.1.2", "private": true, "scripts": { "serve": "vite", "serve:dev": "vite --mode development", "serve:prod": "vite --mode production --force", }, } // npm run serve || npm run serve:dev || npm run serve:prod

@zhangyupeng233
Copy link

我使用nvm, 将我的node从14升级到了16, 问题解决
problem solved, i upgrade my node from 14 to 16, with nvm

@hardeath950
Copy link

Problem solved here, just upgrading Node from 14.15 to v14.19.0

@AngieCooper
Copy link

AngieCooper commented Apr 26, 2022

Problem still occurring with node v16.

ERROR 2:42:49 PM [vite] error while updating dependencies: Error: Build failed with 1 error: error: Cannot read directory "../..": operation not permitted at failureErrorWithLog (/Users/angie.cooper/Documents/Projects/staff-dashboard-fe/node_modules/vite/node_modules/esbuild/lib/main.js:1493:15) at /Users/angie.cooper/Documents/Projects/staff-dashboard-fe/node_modules/vite/node_modules/esbuild/lib/main.js:1151:28 at runOnEndCallbacks (/Users/angie.cooper/Documents/Projects/staff-dashboard-fe/node_modules/vite/node_modules/esbuild/lib/main.js:941:63) at buildResponseToResult (/Users/angie.cooper/Documents/Projects/staff-dashboard-fe/node_modules/vite/node_modules/esbuild/lib/main.js:1149:7) at /Users/angie.cooper/Documents/Projects/staff-dashboard-fe/node_modules/vite/node_modules/esbuild/lib/main.js:1258:14 at /Users/angie.cooper/Documents/Projects/staff-dashboard-fe/node_modules/vite/node_modules/esbuild/lib/main.js:629:9 at handleIncomingPacket (/Users/angie.cooper/Documents/Projects/staff-dashboard-fe/node_modules/vite/node_modules/esbuild/lib/main.js:726:9) at Socket.readFromStdout (/Users/angie.cooper/Documents/Projects/staff-dashboard-fe/node_modules/vite/node_modules/esbuild/lib/main.js:596:7) at Socket.emit (node:events:390:28) at Socket.emit (node:domain:475:12)

@xuoutput
Copy link

Same problem when I using node version 14.15.0, but I switch node to version 16.13.0 this problem did not show up. I delete the 'node_modules/.vite' folder and switch node back to version 14.15.0, this problem show up again.

Node 16.16.0 works. I used Node v16.15.1 before.

@JonathanLopesM
Copy link

Same problem, but i used npm and yarn on project initial, remove package-lock.json, and every ok
THIS RESOLVED FOR ME...!

@hashhesh
Copy link

hashhesh commented Sep 7, 2022

Same problem happened with me after deleting node_module , yarn.lock and run yarn cache clean solve my problem

@AndrewBogdanovTSS
Copy link

Same problem here, I'm using Node 19.0.0, vite 3.1.8, Storybook 7. The error appears when I try to run Storybook. If I run my git bash with admin permissions - the issue disappears, but I would like to not elevate permissions every time

@barusla
Copy link

barusla commented Nov 3, 2022

nx reset worked for me

@AndrewBogdanovTSS
Copy link

@barusla I don't use nx, just calling it via pnpm

@gloriousky
Copy link

gloriousky commented Nov 7, 2022

Same problem when I using node version 14.15.0, but I switch node to version 16.13.0 this problem did not show up. I delete the 'node_modules/.vite' folder and switch node back to version 14.15.0, this problem show up again.

Problem solved. Thanks.

@RafaDev-IT
Copy link

In my case was because I didn't install node, and when I installed it I had to reboot my pc because consoles (cmd, cmder, powershell) wasn't recognition that node was already installed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests