在create react app- App.js中调用node-powershell示例脚本

时间:2019-06-18 12:25:06

标签: node.js reactjs electron

我正在尝试在创建React App App.js中使用node-powershell包。我无法在react render中分配node-powershell示例脚本。这是我正在使用的代码:


class App extends Component {
  render() {

    return (
      $(document).ready(() => {

        // Create the PS Instance
        let ps = new powershell({
            executionPolicy: 'Bypass',
            noProfile: true
        })

        // Load the gun
        ps.addCommand("Roads? Where we're going, we don't need roads.")

        // Pull the Trigger
        ps.invoke()
        .then(output => {
            console.log(output)
        })
        .catch(err => {
            console.error(err)
            ps.dispose()
        })

    })
    )
   }
 }


export default App;

我收到此错误

Objects are not valid as a React child (found: [object HTMLDocument]). If you meant to render a collection of children, use an array instead.
    in App (at src/index.js:6)

我的index.js如下:

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

ReactDOM.render(<App />, document.getElementById('root'));

有人可以帮我吗?

0 个答案:

没有答案