0

New to JS and trying to code a simple reactive bootstrap app with React.js. I am having trouble with a API library, seems like cannot import it.

While test-compiling with webpack I get the following error:

ERROR in ./~/steem/lib/api/index.js
Module not found: Error: Cannot resolve 'file' or 'directory' ./methods in /home/james/Desktop/React-MessageBoard-master/node_modules/steem/lib/api
 @ ./~/steem/lib/api/index.js 33:15-35

ERROR in ./~/steem/config.json
Module parse failed: /home/james/Desktop/React-MessageBoard-master/node_modules/steem/config.json Unexpected token (2:13)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (2:13)

I succesfully installed the API library via npm, and now can be found within node_modules.

Then, I import my library via index.js by using import command.

Below my index.js:

import 'core-js/fn/object/assign';
import React from 'react';
import ReactDOM from 'react-dom';
import App from './components/Main';
import steem from 'steem'
// Render the main component into the dom
ReactDOM.render(<App />, document.getElementById('app'));

and webpack.config.js:

'use strict';

const path = require('path');
const args = require('minimist')(process.argv.slice(2));

// List of allowed environments
const allowedEnvs = ['dev', 'dist', 'test'];

// Set the correct environment
let env;
if (args._.length > 0 && args._.indexOf('start') !== -1) {
  env = 'test';
} else if (args.env) {
  env = args.env;
} else {
  env = 'dev';
}
process.env.REACT_WEBPACK_ENV = env;

/**
 * Build the webpack configuration
 * @param  {String} wantedEnv The wanted environment
 * @return {Object} Webpack config
 */
function buildConfig(wantedEnv) {
  let isValid = wantedEnv && wantedEnv.length > 0 && allowedEnvs.indexOf(wantedEnv) !== -1;
  let validEnv = isValid ? wantedEnv : 'dev';
  let config = require(path.join(__dirname, 'cfg/' + validEnv));
  return config;
}

module.exports = buildConfig(env);

EDIT: There is a methods.json in the API library, found here:

/home/james/Desktop/React-MessageBoard-master/node_modules/steem/lib/api

I thought this might be the root cause... Any help is welcome!

4
  • We need far more information than that to diagnose. Webpack Config, Package.json. Index.js..... Commented Jun 27, 2017 at 8:43
  • import steem from 'steem'; maybe? Commented Jun 27, 2017 at 9:03
  • @matt93 already tried, same error... Commented Jun 27, 2017 at 9:10
  • Possible duplicate of Module parse failed with webpack and react, even using babel-loader Commented Jun 27, 2017 at 9:29

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.