Gulp throwing “is read-only while parsing file” er

2019-09-10 15:39发布

问题:

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

The NotFound is the name of my module.

'use strict';

import React from 'react';

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

export default NotFound;

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).

回答1:

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.