johnnyJ Posted July 10, 2018 Report Share Posted July 10, 2018 (edited) I need add steam-api to my reacr prjct.First I'm running my project with npm start and then I launch steam-user with node steam-api.And when i import steam-user to my react prjct I receive this error https://imgur.com/4xqZZlbMy files:Package.json:{"name": "steamx-app","author": "webif","description": "empty","main": "electron/main.js","version": "0.1.0","private": true,"homepage": "./","scripts": {"start": "nf start","steam-api": "node src/steam-api.js","react-start": "react-scripts start","electron-start": "node electron-wait-react","build": "react-scripts build","test": "react-scripts test --env=jsdom","eject": "react-scripts eject","electron": "electron .","ebuild": "yarn build && node_modules/.bin/build"},"build": {"productName": "steamX","appId": "com.steamx.app","extends": null,"electronVersion": "2.0.4","files": ["build/**/*","electron/*"]},"dependencies": {"electron-titlebar": "0.0.3","react": "^16.4.1","react-dom": "^16.4.1","react-router-dom": "^4.3.1","react-scripts": "1.1.4","readline": "^1.3.0","steam-user": "^3.27.1"},"devDependencies": {"electron": "^2.0.4","electron-builder": "^20.19.2","foreman": "^3.0.1"}}steam-api.js:const SteamUser = require('steam-user')var client = new SteamUser()reactjs file:import React, { Component } from 'react'import LoginForm from './LoginForm'import SteamGuardForm from './SteamGuardForm'import '../../steam-api.js'export default class Login extends Component {state = {accountName: "",password: "",steamGuardCode: ""}inputChangeHandler = (event) => {this.setState({[event.target.id]: event.target.value})}loginHandler = () => {// sessionStorage.setItem("promptSteamGuard", true)}render() {return(<div className="welcome-container"><LoginFormaccountName={this.state.accountName}password={this.state.password}inputChange={this.inputChangeHandler}tryLogin={this.loginHandler}/><SteamGuardFormsteamGuardCode={this.state.steamGuardCode}/></div>)}} Edited July 10, 2018 by johnnyJ Quote Link to comment Share on other sites More sharing options...
Dr. McKay Posted July 10, 2018 Report Share Posted July 10, 2018 You're not running code in the Node.js context. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.