When I try to start the Explorer by the command (./start.sh) this message appear (***** Please check the log [logs/console/console-2019-08-09.log] for any error *****)
Log file contents:
module.js:550
throw err;
^
Error: Cannot find module 'helmet'
at Function.Module._resolveFilename (module.js:548:15)
at Function.Module._load (module.js:475:25)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/home/shikah/fabric/blockchain-explorer/main.js:11:16)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
In the main.js file, I tried to replace "require" with "import" but it does not resolve the problem.
Main.js file contents:
//Part of the main.js file:
const express = require('express');
const helmet = require('helmet');
const path = require('path');
const http = require('http');
const https = require('https');
const fs = require('fs');
const url = require('url');
const WebSocket = require('ws');
const appconfig = require('./appconfig.json');
const helper = require('./app/common/helper');
Follow the latest tutorials from here: https://github.com/hyperledger/blockchain-explorer
./main.sh install
--to install, run tests, and build project
./main.sh clean
--to clean the /node_modules, client/node_modules client/build, client/coverage, app/test/node_modules directories
./main.sh test
--to test REST API, and UI components
--to generate code coverage report
In your case, first run ./main.sh clean then ./main.sh install
Hope it will be solved
Related
I'm building an Alexa skill (deploying via CLI), and all has been going well up until needing to make a few Http calls.
I decided to use first axios, then require in order to do so.
When I installed axios using npm, all seemed well. Adding just the "const axios= require('axios');" line caused my lambda function to start complaining about "Unable to import module 'index'" in the Cloudwatch logs, however, and specifically calling out the line in index.js where I make that require statement.
Removed axios, tried require...same deal.
Any thoughts?
Not actually using the packages yet even, it complains on the require line if I uncomment it.
/* eslint-disable func-names */
/* eslint-disable no-console */
/* eslint-disable no-restricted-syntax */
const error_handler = require('./error_handler');
const globals = require('./globals');
const helper_functions = require('./helper_functions');
const intents_aquarium = require('./intents_aquarium');
const intents_built_in = require('./intents_built_in');
const intents_conversion = require('./intents_conversion');
const intents_helper = require('./intents_helper');
const intents_tank = require('./intents_tank');
const intents_unhandled = require('./intents_unhandled');
const skillBuilder = globals.Alexa.SkillBuilders.standard();
//const request = require('request');
exports.handler = skillBuilder
.addRequestHandlers(
intents_built_in.launchRequest,
intents_built_in.exitHandler,
intents_built_in.sessionEndedRequest,
intents_built_in.helpIntent,
intents_built_in.yesIntent,
intents_built_in.noIntent,
intents_aquarium.aquariumCreateIntentHandler,
intents_aquarium.aquariumCreateSimpleImperial,
intents_conversion.aquariumVolumeIntentGallonsToLitres,
intents_conversion.aquariumVolumeIntentLitresToGallons,
intents_helper.thankYou,
intents_tank.tankObservation,
intents_built_in.fallbackHandler,
intents_unhandled.unhandledIntent,
)
.addErrorHandlers(error_handler.errorHandler)
.withTableName('Tank-Mate')
.withAutoCreateTable(true)
.lambda();
Error looks like this:
Unable to import module 'index': Error
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/var/task/index.js:16:17)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
...which to me looks like it's complaining about the index.js require line.
I have a problem like this. I have created a compile.js file to compile my solidity Contract. In there to handle file I am using the fs-extra module.
This is my compile.js file
const path = require('path');
const solc = require('solc');
const fs = require('fs-extra');
const buildPath = path.resolve(__dirname,'build');
fs.removeSync(buildPath);
const campaignPath= path.resolve(__dirname,'contracts','Campaign.sol');
const source = fs.readFileSync(campaignPath,'utf8');
const output= solc.compile(source,1).contracts;
fs.ensureDirSync(buildPath);
for(let contract in output){
fs.outputJsonSync(
path.resolve(buildPath,contract),
output[contract]
);
}
It works everything finely, without for each loop. When I compile this file with for loop it gives me an error saying that
C:\Users\tharindusa\WebstormProjects\Campaign\node_modules\solc\soljson.js:1
(function (exports, require, module, __filename, __dirname) { var Module;if(!Modu
le)Module=(typeof Module!=="undefined"?Module:null)||{};var moduleOverrides={};fo
r(var key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[k
ey]}}var ENVIRONMENT_IS_WEB=typeof window==="object";var ENVIRONMENT_IS_WORKER=ty
peof importScripts==="function";var ENVIRONMENT_IS_NODE=typeof process==="object"
&&typeof require==="function"&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;var EN
VIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WOR
KER;if(ENVIRONMENT_IS_NODE){if(!Module["print"])Module["print"]=function print(x)
{process["stdout"].write(x+"\n")};if(!Module["printErr"])Module["printErr"]=funct
ion printErr(x){process["stderr"].write(x+"\n")};var nodeFS=require("fs");var nod
ePath=require("path");Module["read"]=function read(filename,binary){filename=node
Path["normalize"](filename);var ret=nodeFS["readFileSy
Error: ENOENT: no such file or directory, open 'C:\Users\tharindusa\WebstormProje
cts\Campaign\ethereum\build\:Campaign.json'
at Object.fs.openSync (fs.js:646:18)
at Object.fs.writeFileSync (fs.js:1299:33)
at Object.writeFileSync (C:\Users\tharindusa\WebstormProjects\Campaign\node_m
odules\fs-extra\node_modules\jsonfile\index.js:117:13)
at Object.outputJsonSync (C:\Users\tharindusa\WebstormProjects\Campaign\node_
modules\fs-extra\lib\json\output-json-sync.js:15:12)
at Object.<anonymous> (C:\Users\tharindusa\WebstormProjects\Campaign\ethereum\compile.js:15:8)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
Can someone help me to solve this problem? .Thank you
Your filename (:Campaign.json) contains a colon, which is invalid in Windows, where colons are only used with drive letters.
I had run into the same problem while compiling my contracts.The issue with your code is that it tries to create a file named :Campaign which is not allowed in windows.
I used the following code to get around it
for(let contract in output){
fs.outputJSONSync(
path.resolve(buildPath,contract.replace(/:/g,'')+'.json'),
output[contract]
);
}
some days ago i've started to write a custom yeoman generator and i want to make a test for it (so i can use travis ecc) but i have a problem when i lunch npm test.
My generator copy only 4 files, a gulpfile.js and 3 files each in a different folder so the final result is:
Project-folder
|
|----- gulpfile.js
|--------production
---------css/main.css
---------html/index.html
---------js/index.js
I want to test my generator so i write this test,i start to write it from the template test provided by generator-generator
app.js
'use strict';
var path = require('path');
var assert = require('yeoman-assert');
var helpers = require('yeoman-test');
describe('generator-postcss-template:app', function () {
before(function () {
return helpers.run(path.join(__dirname, '../generators/app'))
.withPrompts({someAnswer: true})
.toPromise();
});
it('creates files', function () {
assert.file([
'production/css/styles.css',
'production/html/index.html'
]);
});
});
When i lunch the npm test i have this error
module.js:471
throw err;
^
Error: Cannot find module 'gulp-eslint'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/run/media/giulio/Lavoro/Personal/generator-postcss-template/gulpfile.js:4:14)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
npm ERR! Test failed. See above for more details.
i don't know how fix it,test of generator-generator is the same but check only if dummyfile was created and test pass with 100%
Some one can help me?
-- Update--
after deletion of all modules and reinstall it the error was changed
new error
Hey so I'm trying to get Nodejs Koa to talk to postgres using the Koa-pg module, but I keep getting a 'Can't find module pg' error.
I've tried to follow the koa-pg examples, but have come up short...so any advice would on how to progress would be appreciated.
If created my app.js file as follows:
var koa = require('koa');
var route = require('koa-route');
var koaPg = require('koa-pg');
var roads = require('./controllers/roads');
var app = module.exports = koa();
app.use(route.get('/roads/bbox/', roads.bbox));
app.listen(3000);
console.log('listening on port 3000');
And then created my controller file as follows:
var credentials = require('../credentials.js');
var environment = credentials.dev;
app.use(koaPg('postgres://' + environment.user + '#' + environment.host + ':' + environment.port + '/' + environment.database))
module.exports.bbox = function * bbox(next) {
var result = yield this.koaPg.db.client.queryPromise('SELECT now()')
console.log('result: ', result)
this.body = result.rows[0].now.toISOString()
};
But I'm getting the following error:
module.js:338
throw err;
^
Error: Cannot find module 'pg'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (c:\Users\User\Documents\restful_koa\node_modul
es\koa-pg\index.js:12:27)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
This is only a personal project but I'd love to understand where i'm going wrong.
Cheers
As mentioned in the comments:
You need to install the pg module via npm install pg or npm install pg --save if you want to save it to package.json.
The reason you need to do this is koa-pg has co-pg as a dependency so when you install the former the latter is also installed. But pg is not a dependency of co-pg and that is why you have to install it separately.
This question already has answers here:
Cannot run Mocha with CoffeeScript
(6 answers)
Closed 3 years ago.
I'm trying to get Mocha to run in nodejs and expressjs. My test is as follow:
assert = require 'assert'
request = require 'request'
app = require '../../server'
describe "authentication", ->
describe "GET /login ", ->
body = null
before (done) ->
options =
uri: "http://localhost:3000/login"
request options, (err, response, _body) ->
body = _body
done()
it "has user field", ->
assert.ok /user/.test(body)
# assert.match body, /user/
I have added coffee-script as a dependency in my server.js file:
require('coffee-script');
var express = require('express');
var http = require('http');
var path = require('path');
var app = model.exports = express();
And I have a helper file _helper.js:
require('coffee-script')
I run the command:
mocha test/_helper.js test\apps\authentication-test.coffee
which gives the following error:
(exports, require, module, __filename, __dirname) { assert = require 'assert'
SyntaxError: Unexpected string
at Module._compile (module.js:439:25)
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 Module.require (module.js:364:17)
at require (module.js:380:17)
at C:\Program Files\nodejs\node_modules\mocha\lib\mocha.js:172:27
at Array.forEach (native)
at Mocha.loadFiles (C:\Program Files\nodejs\node_modules\mocha\lib\mocha.js:16
9:14)
at Mocha.run (C:\Program Files\nodejs\node_modules\mocha\lib\mocha.js:356:31)
at Object.<anonymous> (C:\Program Files\nodejs\node_modules\mocha\bin\_mocha:3
59:16)
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)
at startup (node.js:119:16)
at node.js:902:3
Anyone sees what I'm missing ?
If you're using CoffeeScript 1.7, you'll need to use require the coffee-script/register module to be able to require and compile .coffee files on the fly (see changelog). Try running Mocha with:
mocha --compilers coffee:coffee-script/register
Or modifying your Mocha helper file:
require('coffee-script/register')
Mocha doesn't check for Coffeescript files by default. You have to specified a compiler option:
mocha --compilers coffee:coffee-script
or add
--compilers coffee:coffee-script
in your mocha.opts file
I needed two changes to get CoffeeScript to work with Mocha:
--require coffee-script/register
--compilers coffee:coffee-script/register