Gulp抛出“解析文件时是只读的".运行Gulp任务时出错 [英] Gulp throwing "is read-only while parsing file" error while running Gulp task

查看:96
本文介绍了Gulp抛出“解析文件时是只读的".运行Gulp任务时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试用JavaScript创建ES6模块,但出现类似Line 20: "NotFound" is read-only while parsing file的错误.

I'm trying to create ES6 module in JavaScript and I get error like: Line 20: "NotFound" is read-only while parsing file.

NotFound是我的模块的名称.

'use strict';

import React from 'react';

const NotFound = React.createClass({
    render: function () {
        return (
            <h1>Not Found!</h1>
        );
    }
});

export default NotFound;

我通过以下方式导入它:import NotFound from './components/NotFound'; 如何解决这个问题?将文件权限更改为777根本没有帮助(我知道这是不正确的,但我正在尝试寻找解决方案).

I'm importing it the following way: import NotFound from './components/NotFound'; How to solve this issue? Changing file rights to 777 doesn't help at all (I know it's incorrect, but I was trying to find a solution).

推荐答案

好吧,看来我在调用import之前已经定义了一个变量.变量名称与导入的模块名称完全相同.那是问题的根源.

Ok, it looks like I had defined a variable before calling import. The variable name was exactly the same as the imported module name. That was the root of the issue.

这篇关于Gulp抛出“解析文件时是只读的".运行Gulp任务时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆