Skip to content
This repository has been archived by the owner on Jun 28, 2022. It is now read-only.

failed to compile #8

Open
richard-hijzen opened this issue Jun 22, 2018 · 3 comments
Open

failed to compile #8

richard-hijzen opened this issue Jun 22, 2018 · 3 comments

Comments

@richard-hijzen
Copy link

I've got 2 errors when i give the command npm start.

Line 8: 'state' is not defined no-undef
Line 16: 'removeContact' is not defined no-undef

Is there something else needed?

@VitskyDs
Copy link

Same here... Can't figure this one out.
Following...

@OzkanAbdullahoglu
Copy link

OzkanAbdullahoglu commented Jul 15, 2018

well It s said that in the course ;

Having state outside the constructor() means it is a class field, which is a proposal for a new change to the language. It currently isn't supported by JavaScript, but thanks to Babel's fantastic powers of transpiling, we can use it!

But It seems that Babel cant help right now , or some other bug ..

I handled that old fashion way to continue on course till I or someone found out the main problem ..

class App extends Component {
constructor(props) {
super(props);
this.state = {
contacts: [
{
id: 'ryan',
name: 'Ryan Florence',
email: 'ryan@reacttraining.com',
avatarURL: 'http://localhost:5001/ryan.jpg'
},
{
id: 'michael',
name: 'Michael Jackson',
email: 'michael@reacttraining.com',
avatarURL: 'http://localhost:5001/michael.jpg'
},
{
id: 'tyler',
name: 'Tyler McGinnis',
email: 'tyler@reacttraining.com',
avatarURL: 'http://localhost:5001/tyler.jpg'
}
]
};
}

@maliayan
Copy link

maliayan commented Jul 27, 2018

I'm not sure, but updating npm and node versions via nvm may solve this problem.

After installing nvm, you can use the codes below. Installing and using the last remote version solved my problem - some different error messages when compiling.
Source

Find out which version of Node.js you are using:
node --version

Find out which versions of Node.js you may have installed and which one of those you're currently using:
nvm ls

List all versions of Node.js available for installation:
nvm ls-remote

Apparently for Windows the command would be rather like this:
nvm ls available

Assuming you would pick Node.js v8.1.0 for installation you'd type the following to install that version:
nvm install 8.1.0

You are then free to choose between installed versions of Node.js. So if you would need to use an older version like v4.2.0 you would set it as the active version like this:
nvm use 4.2

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants