我已经安装了来自reactjs的反应js,但在遇到问题时: -
我当前的节点版本是v7.4.0 要运行的命令: -
npm start
/home/Desktop/hello-world/node_modules/spawn-sync/node_modules/try-thread-sleep/node_modules/thread-sleep/index.js:19
childProcess.execFileSync(nodeBin, [ '-e',
^
TypeError: Object #<Object> has no method 'execFileSync'
at sleep (/home/Desktop/hello-world/node_modules/spawn-sync/node_modules/try-thread-sleep/node_modules/thread-sleep/index.js:19:16)
at invoke (/home/Desktop/hello-world/node_modules/spawn-sync/lib/spawn-sync.js:62:5)
at spawnSyncFallback (/home/Desktop/hello-world/node_modules/spawn-sync/lib/spawn-sync.js:85:3)
at Function.spawnSync [as sync] (/home/Desktop/hello-world/node_modules/cross-spawn/index.js:46:14)
at Object.<anonymous> (/home/Desktop/hello-world/node_modules/react-scripts/bin/react-scripts.js:11:22)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
npm ERR! weird error 8
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian
npm ERR! not ok code 0
App.js代码详情: - 显示徽标和其他详细信息
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
class App extends Component {
render() {
return (
<div className="App">
<div className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<h2>Welcome to React</h2>
</div>
<p className="App-intro">
To get started, edit <code>src/App.js</code> and save to reload.
</p>
</div>
);
}
}
export default App;
index.js代码详情: -
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import './index.css';
ReactDOM.render(
<App />,
document.getElementById('root')
);
下面的Package.json内容: -
{
"name": "hello-world",
"version": "0.1.0",
"private": true,
"devDependencies": {
"react-scripts": "0.9.0"
},
"dependencies": {
"react": "^15.4.2",
"react-dom": "^15.4.2",
"spawn-sync": "~1.0.15"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
需要帮助才能运行hello world程序。