Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

npm - Error when I tried to follow the ReactJS.org documentation

I am following the instructions here: https://reactjs.org/tutorial/tutorial.html#setup-option-2-local-development-environment.

After step 6 I am being asked to run npm start. This is the result:

enter image description here

This is what is inside package.json in the scripts:

"scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },

This is my index.js file for now:

import ReactDOM from 'react-dom';
import React from 'react';
import './index.css';

Basically I just ran npx create-react-app my-app and tried to replace what is inside src with a .js file.

question from:https://stackoverflow.com/questions/65893197/error-when-i-tried-to-follow-the-reactjs-org-documentation

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Looks like your first two characters in the index.js file are some random characters. Get rid of them. It should work. Use a proper editor that supports UTF 8 and BOM.

preview

I don't think there's anything wrong with the documentation. Also, they say:

We strongly recommend typing code by hand as you’re working through the tutorial and not using copy/paste. This will help you develop muscle memory and a stronger understanding.

Not just that, the HTML might have constructed using other generators that might add non-visual contents. From the above screenshot, it's very evident that there are two non-visual contents in the start of the line. Please remove that.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...