【问题标题】:Getting "Warning: EPERM, operation not permitted" when using grunt-contrib-copy but file does copy使用 grunt-contrib-copy 但文件确实复制时出现“警告:EPERM,不允许操作”
【发布时间】:2015-03-06 22:47:24
【问题描述】:

我想复制build目录下的style.css来覆盖项目主目录下的style.css。

这是我的文件结构

project
├── assets
│   ├── styles
│   │  └── build
│   │       └── style.css
│   └── gruntfile.js
└── style.css

在我的 gruntfile.js 文件中,我有:

copy: {
    dev: {
        files: [{
            cwd: 'styles/build/',
            src: 'style.css',
            dest: '../',
            expand: true
        }]
    }
},    

当我运行 grunt 时,我得到这个错误:

Running "copy:dev" (copy) task
Warning: EPERM, operation not permitted '../style.css' Use --force to continue.

Aborted due to warnings.

但它确实复制了文件。 我不知道为什么我会收到这个错误。

提前致谢。

【问题讨论】:

    标签: gruntjs grunt-contrib-copy


    【解决方案1】:

    你的路径不正确,../dest 也不正确,你必须把你的目的地放在'.'

    试试看:

    copy: {
        dev: {
            files: [{
                cwd: 'assets/styles/build/',
                src: 'style.css',
                dest: '../',
                expand: true
            }]
        }
    },  
    

    如果您使用的是 Windows,请尝试以管理员身份打开您的 CMD。也许你的 style.css 有权限问题

    【讨论】:

    • 从我给出的文件结构来看,你是对的,但是我弄错了! gruntfile.js 文件位于资产目录中,而不是项目目录中。我已经对原始问题进行了更改。对此感到抱歉。
    • 我在 Mac 上,并且 style.css 的权限是正确的。
    • 恐怕无法在父目的地移动文件。为什么不将你的 gruntfile 移动到根文件夹?
    • 它实际上是在复制文件。它有效,它只是给了我那个错误并在之后中止。
    • 我听取了您的建议并将 gruntfile 移动到项目目录并相应地更改了复制代码,但我得到了同样的错误(再次成功复制文件)。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-08-08
    • 2017-01-07
    • 1970-01-01
    • 1970-01-01
    • 2021-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多