gpt4 book ai didi

javascript - Babel CLI --out-dir 在第二次编译时遇到权限错误

转载 作者:行者123 更新时间:2023-11-30 20:51:14 26 4
gpt4 key购买 nike

我遇到了一个奇怪的错误,似乎在 Windows 10 上给我权限问题。我正在使用 Babel CLI 编译一些 ES6 代码,使用 --out-file 效果很好,它将覆盖文件很好, by --out-dir 没有。这是我的 package.json 的相关部分:

{
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-minify": "^0.2.0",
"babel-preset-env": "^1.6.0"
},
"scripts": {
"build-components": "babel Scripts/Components --out-file Scripts/Compiled/components.js",
"build-pages": "babel Scripts/Pages --out-dir Scripts/Compiled/Pages",
"watch-components": "babel Scripts/Components -w --out-file Scripts/Compiled/components.js",
"watch-pages": "babel Scripts/Pages -w --out-dir Scripts/Compiled/Pages",
"build-js": "npm run build-components && npm run build-pages"
}
}

我正在 Visual Studio 中构建它并使用 Task Runner Explorer包来运行我的命令(尽管它仍然无法从 PowerShell 运行,或者将其作为项目中的构建命令运行)。该插件在构建时运行“npm run build-js”,之后运行“npm run watch-components”和“npm run watch-pages”观察任何变化。 'npm run watch-pages' 每次都会失败,'npm run build-pages' 如果它输出的文件已经存在,也会失败。到目前为止,我找到的唯一解决方案是每次更改“Scripts/Pages”中的文件时删除“Scripts/Compiled/Pages”文件夹,这违背了 watch 命令的目的,而且通常每次都必须这样做很烦人,尤其是当我进行大量文件更改时。组件的两个构建命令每次都有效,并且会毫无问题地覆盖旧文件。

> babel Scripts/Pages --out-dir Scripts/Compiled/Pages
Error: EPERM: operation not permitted, open 'D:\Projects\PasswordReset\Trunk\STS.PasswordReset.Web\Scripts\Compiled\Pages\Index.Vue.js'
at Error (native)
at Object.fs.openSync (fs.js:584:18)
at fs.writeFileSync (fs.js:1224:33)
at outputFileSync (D:\Projects\PasswordReset\Trunk\STS.PasswordReset.Web\node_modules\output-file-sync\index.js:45:3)
at write (D:\Projects\PasswordReset\Trunk\STS.PasswordReset.Web\node_modules\babel-cli\lib\babel\dir.js:33:5)
at handleFile (D:\Projects\PasswordReset\Trunk\STS.PasswordReset.Web\node_modules\babel-cli\lib\babel\dir.js:43:7)
at D:\Projects\PasswordReset\Trunk\STS.PasswordReset.Web\node_modules\babel-cli\lib\babel\dir.js:61:9
at Array.forEach (native)
at handle (D:\Projects\PasswordReset\Trunk\STS.PasswordReset.Web\node_modules\babel-cli\lib\babel\dir.js:59:29)
at Array.forEach (native)
npm ERR! Windows_NT 10.0.15063
npm ERR! argv "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Enterprise\\Web\\External\\Node.exe" "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Enterprise\\Web\\External\\node_modules\\npm\\bin\\npm-cli.js" "run" "build-pages" "--color=always"
npm ERR! node v5.4.1
npm ERR! npm v3.3.4
npm ERR! code ELIFECYCLE
npm ERR! STS-VueApp@1.0.0 build-pages: `babel Scripts/Pages --out-dir Scripts/Compiled/Pages`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the STS-VueApp@1.0.0 build-pages script 'babel Scripts/Pages --out-dir Scripts/Compiled/Pages'.
npm ERR! This is most likely a problem with the STS-VueApp package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! babel Scripts/Pages --out-dir Scripts/Compiled/Pages
npm ERR! You can get their info via:
npm ERR! npm owner ls STS-VueApp
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! D:\Projects\PasswordReset\Trunk\STS.PasswordReset.Web\npm-debug.log
Process terminated with code 1.

我认为这可能与我的项目中未包含的文件有关,因为如果我的“Scripts/Compiled”文件夹未包含在项目中,我会从组件构建中得到类似的错误,但包含'Scripts/Compiled/Pages' 仍然给我同样的错误,包括实际的输出文件,即:'Scripts/Compiled/Pages/Index.js' 也没有修复它。

有什么想法吗? :\

最佳答案

这只是我的想法。但是,请你仔细检查一下:

  • 您是否以管理员身份运行 VS?
  • 您是否以管理员身份运行 Task Runner Explorer?

确保两者都在管理员下工作。

关于javascript - Babel CLI --out-dir 在第二次编译时遇到权限错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48159518/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com