Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Babel CLI--out dir在第二次编译时遇到权限错误_Javascript_Visual Studio_Asp.net Mvc 5_Babeljs - Fatal编程技术网

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

Javascript Babel CLI--out dir在第二次编译时遇到权限错误,javascript,visual-studio,asp.net-mvc-5,babeljs,Javascript,Visual Studio,Asp.net Mvc 5,Babeljs,我遇到了一个奇怪的错误,它似乎给了我在Windows10上的权限问题。我正在使用Babel CLI编译一些ES6代码,使用--out file可以很好地覆盖文件,而--out dir则不行。以下是my package.json的相关部分: { "devDependencies": { "babel-cli": "^6.26.0", "babel-minify": "^0.2.0", "babel-preset-env": "^1.6.0"

我遇到了一个奇怪的错误,它似乎给了我在Windows10上的权限问题。我正在使用Babel CLI编译一些ES6代码,使用--out file可以很好地覆盖文件,而--out dir则不行。以下是my 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"
    }
}
我正在VisualStudio中构建它,并使用包来运行我的命令(尽管它仍然无法从PowerShell中运行,或者在项目中作为构建命令运行)。插件在构建时运行“npm运行构建js”,然后运行“npm运行监视组件”和“npm运行监视页面””,以监视任何更改npm运行监视页面每次都会失败,如果输出的文件已经存在,“npm运行生成页面”也会失败。到目前为止,我找到的唯一解决方案是,每次我对“脚本/页面”中的文件进行更改时,都要删除“脚本/编译/页面”文件夹,这违背了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
  • 您是否以管理员身份运行任务运行器资源管理器

确保两者都在Administrator下工作。

我遇到了类似的问题,问题似乎是babel正在从VSS的源代码管理下的文件上移动只读属性,即从VSS中拉取一个文件,该文件带有只读属性。它上面的手表会将其传输到目标文件夹中,并带有只读功能。后续传输文件失败,因为目标文件设置为只读时不会被覆盖

我仍然在为这个问题寻找正确的解决方案,但目前我已经通过一个任务运行程序命令破解了临时修复程序,该命令删除了整个目标文件夹上的只读内容

"babelJsxTranspileInit": "attrib -r [targetFolder]  /s",

为我工作。尝试禁用反病毒、以管理员身份运行git bash、禁用winpty等,但只有您的成功。干杯