Openshift 503 on node.js app with hapi - javascript

I have a node.js app using hapi that I'm trying to host on OpenShift. I've uploaded the app to the server, it apparently reads the package.json file fine and runs the app.js file.
However, when I visit the site, I receive a 503 error.
Package.json file:
{
"name": "app",
"version": "1.0.0",
"description": "",
"main": "server.js",
"dependencies": {
"after": "^0.8.1",
"bcryptjs": "2.3.0",
"bootstrap": "^3.3.6",
"forever": "^0.15.1",
"gulp": "^3.9.0",
"gulp-nodemon": "^2.0.4",
"handlebars": "4.0.5",
"hapi": "^8.8.1",
"hapi-auth-cookie": "^3.1.0",
"knex": "^0.9.0",
"mysql": "^2.9.0",
"nodemon": "^1.8.0",
"request": "^2.69.0",
"tree-model": "^1.0.4"
},
"devDependencies": {},
"scripts": {
"start": "node server.js"
}
"author": "",
"license": "ISC"
}
*note: repository information was removed from the package.json paste.
app.js file:
var Hapi = require('hapi');
var fs = require('fs');
fs.readFile('./bin/dbcfg.txt', 'utf8', function(err, data){
if (err){
console.log(err);
}
else{
data = JSON.parse(data);
process.env.client = data.client;
process.env.host = data.connection.host;
process.env.user = data.connection.user;
process.env.password = data.connection.password;
process.env.database = data.connection.database;
fs.readFile('./bin/strategycfg.txt', 'utf8', function(err, data){
if(err){
console.log(err);
}
else{
var strategyCFG = JSON.parse(data);
server = new Hapi.Server();
server.connection({ port : 3000, address: process.env.OPENSHIFT_NODEJS_IP || '127.0.0.1' });
server.register(require('hapi-auth-cookie'), function(err){
if(err){
console.log(err);
}
server.auth.strategy('default', 'cookie',strategyCFG);
server.auth.default('default');
const defaultContext = {
title: 'App'
};
server.views({
engines: {
html: require('handlebars')
},
context: defaultContext,
path: ['public/html', 'private/html'],
layoutPath: 'public/templates',
layout: 'default'
//,
//helpersPath: 'views/helpers',
//partialsPath: 'views/partials'
});
});
server.route(require('./lib/Routes'));
server.start(function() {
console.log('Running on 3000');
});
}
});
}
});
I ran rhc tail -a appname and received this:
==> app-root/logs/haproxy.log <==
[WARNING] 090/180806 (276379) : config : log format ignored for proxy 'stats' since it has no log address.
[WARNING] 090/180806 (276379) : config : log format ignored for proxy 'express' since it has no log address.
[WARNING] 090/180806 (276379) : Server express/local-gear is DOWN, reason: Layer4 connection problem, info: "Connection refused", check duration: 0ms. 0 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
[ALERT] 090/180806 (276379) : proxy 'express' has no server available!
[WARNING] 090/180919 (276379) : Server express/local-gear is DOWN for maintenance.
[WARNING] 090/180919 (279772) : config : log format ignored for proxy 'stats' since it has no log address.
[WARNING] 090/180919 (279772) : config : log format ignored for proxy 'express' since it has no log address.
[WARNING] 090/180919 (279772) : Server express/local-gear is DOWN, reason: Layer4 connection problem, info: "Connection refused", check duration: 0ms. 0 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
[ALERT] 090/180919 (279772) : proxy 'express' has no server available!
[WARNING] 090/180923 (279772) : Server express/local-gear is DOWN for maintenance.
==> app-root/logs/haproxy_ctld.log <==
I, [2016-03-30T22:04:51.536078 #521102] INFO -- : Starting haproxy_ctld
I, [2016-03-30T22:11:34.136340 #49489] INFO -- : Starting haproxy_ctld
I, [2016-03-30T22:25:04.802167 #98826] INFO -- : Starting haproxy_ctld
I, [2016-03-30T22:29:56.842182 #117627] INFO -- : Starting haproxy_ctld
I, [2016-03-30T22:32:36.247075 #130978] INFO -- : Starting haproxy_ctld
I, [2016-03-30T22:39:12.046805 #156995] INFO -- : Starting haproxy_ctld
I, [2016-03-30T23:01:39.741187 #237078] INFO -- : Starting haproxy_ctld
I, [2016-03-30T23:07:00.948129 #255019] INFO -- : Starting haproxy_ctld
I, [2016-03-31T18:08:07.635718 #276393] INFO -- : Starting haproxy_ctld
I, [2016-03-31T18:09:20.552771 #279795] INFO -- : Starting haproxy_ctld
==> app-root/logs/npm-debug.log <==
5 error package.json npm can't find a package.json file in your current directory.
6 error System Linux 2.6.32-573.12.1.el6.x86_64
7 error command "node" "/opt/rh/nodejs010/root/usr/bin/npm" "install"
8 error cwd /var/lib/openshift/xxxxxxxx/app-root/logs
9 error node -v v0.10.35
10 error npm -v 1.4.28
11 error path /var/lib/openshift/xxxxxxxx/app-root/logs/package.json
12 error code ENOPACKAGEJSON
13 error errno 34
14 verbose exit [ 34, true ]
==> app-root/logs/nodejs.log <==
DEBUG: Sending SIGTERM to child...
DEBUG: Running node-supervisor with
DEBUG: program 'server.js'
DEBUG: --watch '/var/lib/openshift/xxxxxxx/app-root/data/.nodewatch'
DEBUG: --ignore 'undefined'
DEBUG: --extensions 'node|js|coffee'
DEBUG: --exec 'node'
DEBUG: Starting child process with 'node server.js'
DEBUG: Watching directory '/var/lib/openshift/xxxxxxx/app-root/data/.nodewatch' for changes.
Running on 3000
The "Running on 3000" makes me think the app is running, but the OpenShift site gives me a 503.
Any and all help would be greatly appreciated. Thanks, everyone!

Can you try to use host instead of address like this:
server.connection({ host:'0.0.0.0', port: 3000});
Also I think open shift also expose an environment variable for the port.

Related

Smart contracts won't deploy to a goQuorum blockchain

I installed goQuorum with quorum-wizard with 4 quorum nodes and 4 tessera nodes on IBFT. When I start the network with "./start.sh" I get
Starting Quorum network...
Waiting until all Tessera nodes are running...
Waiting until all Tessera nodes are running...
All Tessera nodes started
Starting Quorum nodes
Successfully started Quorum network.
--------------------------------------------------------------------------------
Tessera Node 1 public key:
BULeR8JyUWhiuuCMU/HLA0Q5pzkYT+cHII3ZKBey3Bo=
Tessera Node 2 public key:
QfeDAys9MPDs2XHExtc84jKGHxZg/aj52DTh0vtA3Xc=
Tessera Node 3 public key:
1iTZde/ndBHvzhcl7V68x44Vx7pl8nwx9LqnM/AfJUg=
Tessera Node 4 public key:
oNspPPgszVUFw0qmGFfWwh1uxVUXgvBxleXORHj07g8=
--------------------------------------------------------------------------------
when I run "nmap -p 21000-21100" I get
21000/tcp open irtrans
21001/tcp open unknown
21002/tcp open unknown
21003/tcp open unknown
This is my truffle-config.js
const HDWalletProvider = require("#truffle/hdwallet-provider");
const mnemonic = "not my real mn mon ic num phrase dum get l gg";
module.exports = {
networks: {
rinkeby: {
provider: function() {
return new HDWalletProvider(mnemonic, "https://rinkeby.infura.io/v3/"+mnemonic);
},
network_id: '*',
timeoutBlocks: 100000,
networkCheckTimeout:2000000
},
quorum: {
provider: function() {
return new HDWalletProvider(mnemonic, "http://127.0.0.1:21000/", chainId=10);
},
network_id: '*',
type: 'quorum',
timeoutBlocks: 100000,
networkCheckTimeout:2000000
},
compilers: {
solc: {
version: "0.5.0",
settings: {
optimizer: {
enabled: true, // Default: false
runs: 1000 // Default: 200
},
evmVersion: "homestead" // Default: "byzantium"
}
}
}
};
When I cd in to the directory with the truffle-config.js and I run truffle deploy --reset --network quorum to compile my smart contracts I get the following error.
Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.
/root/dapp1/Dapp/node_modules/web3-core-helpers/src/errors.js:42
return new Error(message);
^
Error: PollingBlockTracker - encountered an error while attempting to update latest block:
Error: Invalid JSON RPC response: ""
at Object.InvalidResponse (/root/dapp1/Dapp/node_modules/web3-core-helpers/src/errors.js:42:16)
at XMLHttpRequest.request.onreadystatechange (/root/dapp1/Dapp/node_modules/web3-providers-http/src/index.js:92:32)
at XMLHttpRequestEventTarget.dispatchEvent (/root/dapp1/Dapp/node_modules/xhr2-cookies/xml-http-request-event-target.ts:44:13)
at XMLHttpRequest._setReadyState (/root/dapp1/Dapp/node_modules/xhr2-cookies/xml-http-request.ts:219:8)
at XMLHttpRequest._onHttpRequestError (/root/dapp1/Dapp/node_modules/xhr2-cookies/xml-http-request.ts:379:8)
at ClientRequest.<anonymous> (/root/dapp1/Dapp/node_modules/xhr2-cookies/xml-http-request.ts:266:37)
at ClientRequest.emit (events.js:315:20)
at Socket.socketOnEnd (_http_client.js:493:9)
at Socket.emit (events.js:327:22)
at endReadableNT (internal/streams/readable.js:1327:12)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
at PollingBlockTracker._performSync (/root/dapp1/Dapp/node_modules/eth-block-tracker/src/polling.js:51:24)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
I can deploy the smart contracts to rinkeby test net within this environment but I can't get smart contracts to deploy to quorum
I am using
Node v14.16.1
Ubuntu 18.04 (64 Bit)
Quorum 21.1.0
Web3.js v1.3.5
Truffle v5.3.4 (core: 5.3.4)
solidity v0.5.0
I've not used truffle with HDWalletProvider, which I believe is from an older version of Truffle. I'm not certain that will set up the node connection.
We would normally set up the configuration like the following in the quorum: {} section:
host: "localhost",
port: 22001,
type: "quorum"
I would suggest using that and see if it works.
Take a look at the truffle docs for working with quorum: https://www.trufflesuite.com/docs/truffle/distributed-ledger-support/working-with-quorum
Did you change from the default ports in the quorum-wizard?
The default for the node 1 RPC is 22000, the 21000 range is for p2p networking.
I would set the host and port per Satpal's answer above, as in the hdwallet documentation here.

how can I run a web-app with a docker-container?

I have a simple web-app, with an index.html, app.js and package.json files.
Now, I want to run it via a docker-container. On my local machine, I can run the app with npm install and then npm start.
When I try to run it via docker-compose up, I get the following error message:
Couldn't connect to Docker daemon at http+docker://localunixsocket - is it running?
If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable
My Dockerfile looks as follows:
FROM node:8.11
WORKDIR /usr/src/app
ARG NODE_ENV
ENV NODE_ENV $NODE_ENV
COPY package.json /usr/src/app/
RUN npm install
COPY . /usr/src/app
# replace this with your application's default port
EXPOSE 8000
CMD [ "npm", "run", "dev" ]
and docker-compose.yml looks as this:
version: "2"
services:
web:
build: .
command: nodemon -L --inspect=0.0.0.0:5858
volumes:
- .:/usr/src/app
ports:
- "8000:8000"
- "5858:5858"
Actually, the app should run under localhost:8000 or under localhost:5858 for debug-mode.
Any idea what is wrong with Dockerfile or the docker-compose.yml? I already tried the fixes described here, but both suggestions don't work for me, so there must be something else wrong.
Thanks in advance and kind regards.
PS: If you need more code, please feel free to tell me and I add it to the question.
Update: the package.json looks as follows:
{
"name": "custom-meta-model",
"version": "0.0.0",
"description": "An bpmn-js modeler extended with a custom meta-model",
"main": "app/index.js",
"scripts": {
"all": "grunt",
"dev": "grunt auto-build"
},
"keywords": [
"bpmnjs-example"
],
"author": {
"name": "Nico Rehwaldt",
"url": "https://github.com/nikku"
},
"contributors": [
{
"name": "bpmn.io contributors",
"url": "https://github.com/bpmn-io"
}
],
"license": "MIT",
"devDependencies": {
"babel-core": "^6.26.3",
"babel-preset-env": "^1.7.0",
"babelify": "^8.0.0",
"grunt": "^1.2.0",
"grunt-browserify": "^5.3.0",
"grunt-contrib-watch": "^1.1.0",
"grunt-contrib-connect": "^2.1.0",
"grunt-contrib-copy": "^1.0.0",
"load-grunt-tasks": "^5.1.0",
"stringify": "^5.2.0"
},
"dependencies": {
"bpmn-js": "^7.2.0",
"diagram-js": "^6.6.1",
"jquery": "^3.5.1"
}
}
Update 2: It looks a bit better now, I corrected the CMD-Command in Dockerfile. Now the output tells me that 'grunt' was not found. Concrete:
Step 9/9 : CMD [ "npm", "run", "dev" ]
---> Running in f51692a86908
Removing intermediate container f51692a86908
---> 53e88bbb46c4
Successfully built 53e88bbb46c4
Successfully tagged overlayexample2_web:latest
Recreating overlayexample2_web_1
Attaching to overlayexample2_web_1
web_1 |
web_1 | > custom-meta-model#0.0.0 dev /usr/src/app
web_1 | > grunt auto-build
web_1 |
web_1 | sh: 1: grunt: not found
web_1 | npm ERR! code ELIFECYCLE
web_1 | npm ERR! syscall spawn
web_1 | npm ERR! file sh
web_1 | npm ERR! errno ENOENT
web_1 | npm ERR! custom-meta-model#0.0.0 dev: `grunt auto-build`
web_1 | npm ERR! spawn ENOENT
web_1 | npm ERR!
web_1 | npm ERR! Failed at the custom-meta-model#0.0.0 dev script.
web_1 | npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
web_1 | npm WARN Local package.json exists, but node_modules missing, did you mean to install?
web_1 |
web_1 | npm ERR! A complete log of this run can be found in:
web_1 | npm ERR! /root/.npm/_logs/2020-08-21T17_03_50_937Z-debug.log
overlayexample2_web_1 exited with code 1
How can I fix it?
Maybe the Gruntfile.js has to be modified, currently it looks like this:
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
grunt.loadNpmTasks('grunt-docker');
grunt.initConfig({
browserify: {
options: {
transform: [
[ 'stringify', {
extensions: [ '.bpmn' ]
} ],
[ 'babelify', {
global: true
} ]
]
},
watch: {
options: {
watch: true
},
files: {
'dist/index.js': [ 'app/**/*.js' ]
}
},
app: {
files: {
'dist/index.js': [ 'app/**/*.js' ]
}
}
},
copy: {
diagram_js: {
files: [ {
src: require.resolve('diagram-js/assets/diagram-js.css'),
dest: 'dist/css/diagram-js.css'
} ]
},
app: {
files: [
{
expand: true,
cwd: 'app',
src: ['**/*.*', '!**/*.js'],
dest: 'dist'
}
]
}
},
watch: {
options: {
livereload: false
},
samples: {
files: [ 'app/**/*.*' ],
tasks: [ 'copy:app' ]
},
},
connect: {
livereload: {
options: {
port: 8000,
livereload: true,
hostname: '*',
open: false,
base: [
'dist'
]
}
}
}
});
// tasks
grunt.registerTask('build', [ 'browserify:app', 'copy' ]);
grunt.registerTask('auto-build', [
'copy',
'browserify:watch',
'connect:livereload',
'watch'
]);
grunt.registerTask('default', [ 'build' ]);
};
You have to enable and start the Docker daemon in your system.
If you are on Linux, try it: sudo systemctl enable docker && sudo systemctl start docker
If systemctl is not recognized as a command, you should use: service docker start.
The systemctl start is required for the first run because enable will only auto-start the daemon after reboot. After enabling it, it will auto start on boot.
Your Docker service is not running, you need to start Docker Desktop manually.
Nothing wrong with Dockerfile and docker-compose.file.
Try to run with sudo:
sudo docker-compose up

403 error when deploying a Node.js app on Heroku

Earlier, I was getting the following error (from the Chrome console) when trying to open a Node.js app using Heroku:
Refused to load the image 'https://browser-rpg-app.herokuapp.com/favicon.ico' because it violates the following Content Security Policy directive: "default-src 'none'". Note that 'img-src' was not explicitly set, so 'default-src' is used as a fallback.
This was accompanied by a 403. I managed to fix it by adding this line:
<meta http-equiv="Content-Security-Policy" content="default-src 'self' https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js 'unsafe-inline'">
Now the first error is gone, but I'm still getting a 403. I can run the app flawlessly on heroku local web, but not when I actually deploy. Here's what the log says:
2019-12-02T22:41:29.000000+00:00 app[api]: Build succeeded
2019-12-02T22:41:32.617542+00:00 heroku[web.1]: Starting process with command `node app.js`
2019-12-02T22:41:36.786903+00:00 heroku[web.1]: State changed from starting to up
2019-12-02T22:42:00.484013+00:00 app[web.1]: ForbiddenError: Forbidden
2019-12-02T22:42:00.484062+00:00 app[web.1]: at SendStream.error (/app/node_modules/send/index.js:270:31)
2019-12-02T22:42:00.484066+00:00 app[web.1]: at SendStream.pipe (/app/node_modules/send/index.js:553:12)
2019-12-02T22:42:00.484068+00:00 app[web.1]: at sendfile (/app/node_modules/express/lib/response.js:1103:8)
2019-12-02T22:42:00.484071+00:00 app[web.1]: at ServerResponse.sendFile (/app/node_modules/express/lib/response.js:433:3)
2019-12-02T22:42:00.484074+00:00 app[web.1]: at index (/app/routes/index.js:9:9)
2019-12-02T22:42:00.484077+00:00 app[web.1]: at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
2019-12-02T22:42:00.484079+00:00 app[web.1]: at next (/app/node_modules/express/lib/router/route.js:137:13)
2019-12-02T22:42:00.484081+00:00 app[web.1]: at Route.dispatch (/app/node_modules/express/lib/router/route.js:112:3)
2019-12-02T22:42:00.484083+00:00 app[web.1]: at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
2019-12-02T22:42:00.484085+00:00 app[web.1]: at /app/node_modules/express/lib/router/index.js:281:22
2019-12-02T22:42:00.482239+00:00 heroku[router]: at=info method=GET path="/" host=browser-rpg-app.herokuapp.com request_id=845c8d30-4ca7-44f4-ab69-ae312e722b1b fwd="68.174.27.246" dyno=web.1 connect=1ms service=21ms status=403 bytes=380 protocol=https
As you can see, there's no helpful message or explanation, it just says forbidden. I really have no clue what the problem could be, but here's a bunch of important/relevant files:
app.js:
const express = require("express");
const configRoutes = require("./routes");
const static = express.static(__dirname + '/public');
const app = express();
app.use("/public", static);
var bodyParser = require('body-parser');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
const cookieParser = require("cookie-parser");
app.use(cookieParser());
configRoutes(app);
app.listen(process.env.PORT || 3000, () => {
console.log("The application is running on http://localhost:3000");
if (process && process.send) process.send({done: true});
});
package.json:
{
"name": "browserrpg",
"version": "1.0.0",
"description": "",
"main": "app.js",
"engines": {
"node": "10.16.3"
},
"dependencies": {
"angular": "^1.7.2",
"angular-route": "^1.7.2",
"body-parser": "^1.18.3",
"cookie-parser": "^1.4.3",
"express": "^4.16.3",
"mongodb": "^3.1.1",
"npm": "^6.2.0",
"uuid": "^3.3.2"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node app.js"
},
"repository": {
"type": "git",
"url": (git url here, removed for privacy)
},
"author": "",
"license": "ISC",
}
Procfile:
web: node app.js
In case it's relevant, here's the "/" route that Heroku calls:
const index = (req, res) => {
res.sendFile(path.join(__dirname, "..\\public\\html", "index.html"));
return;
}
And here's the constructor that sets up all the routes:
const constructorMethod = app => {
app.get("/", index);
app.get("/game", gameGet);
app.post("/game", gamePost);
app.use("*", (req, res) => {
res.status(404).json({ error: "Not found" });
});
};
Here's my file structure as well:
BrowserRPG
│ README.md
│ Procfile
| app.js
| mongoCollections.js
| mongoConnection.js
| package.json
| settings.json
│
└───data
│ enemydata.js
│ gamecalc.js
| gamedata.js
| index.js
│
│
└───public
│
└───css
| main.css
|
└───html
| game.html
| index.html
|
└───js
| angular.js
| angularActiveGame.js
|
└───routes
| index.js
I'm also using a mongodb database, but I don't think that's causing the problem, considering that I haven't even attempted to connect it to Heroku yet, and you don't need to have a db running to get to the first page of the app. Is there something here that might be causing the error? Thanks.
So I finally figured it out, the solution was actually annoyingly simple. In my "/" GET route, the path contains a .., which was being viewed as malicious, and therefore rejected. I changed it to this:
res.sendFile(path.join(appRoot, "public/html", "index.html"));
appRoot is a global variable that points to the root directory of the application. Hopefully this helps someone who may be having a similar issue.

Can't find the module after extension is installed

I'm trying to create VS Code extension. It works when fine when I develop, however when I create the package and install it to VS Code it is failing with following error:
ERR Cannot find module 'request': Error: Cannot find module 'request'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:602:15)
at Function.Module._load (internal/modules/cjs/loader.js:528:25)
at Function.t._load (c:\Users\USER\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:729:537)
at Function.t.getExtensionPathIndex.then.a._load (c:\Users\USER\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:691:639)
at Function.t.getExtensionPathIndex.then.r._load (c:\Users\USER\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:655:197)
at Module.require (internal/modules/cjs/loader.js:658:17)
at n (c:\Users\USER\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\loader.js:15:874)
at openBambooPlanUrlInBrowser.GIT.getGitBranchFromFileName (C:\Users\USER\.vscode\extensions\dUSER.markdown-table-of-contents-0.0.1\out\extension.js:397:41)
at getGitBranchFromFileName.exec (C:\Users\USER\.vscode\extensions\dUSER.markdown-table-of-contents-0.0.1\out\extension.js:383:17)
at ChildProcess.exithandler (child_process.js:294:7)
at ChildProcess.emit (events.js:182:13)
at maybeClose (internal/child_process.js:961:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:248:5)
my code:
async openBambooPlanUrlInBrowser(fileName: string) {
new GIT().getGitBranchFromFileName(fileName, (branch: string) => {
var config: any = vscode.workspace.getConfiguration('markdown-table-of-contents').get('bitbucketRepositories');
for (var setting of config) {
if (fileName.toLowerCase().startsWith(setting.folder.toLowerCase())) {
branch = branch.replace('/', '-');
let bambooHost = vscode.workspace.getConfiguration('markdown-table-of-contents').get('atlassianBambooHost');
const request = require('request');
request(
{
url: `${bambooHost}/rest/api/latest/plan/${setting.bambooPlanKey}/branch/${branch}.json`,
headers: {
"Authorization": 'Basic ' + vscode.workspace.getConfiguration('markdown-table-of-contents').get('atlassianAuthHash')
}
},
(error: string, response: string, body: string) => {
let planKey = JSON.parse(body).key;
vscode.env.openExternal(vscode.Uri.parse(`${bambooHost}/browse/${planKey}`));
}
);
}
}
});
}
dependencies from package.json
"dependencies": {
"child_process": "^1.0.2",
"clipboardy": "^1.2.3",
"fs": "0.0.1-security",
"iconv-lite": "^0.4.24",
"path": "^0.12.7",
"request": "^2.88.0",
"util": "^0.11.1",
"xml2js": "^0.4.19",
"xmldom": "^0.1.27"
}
root folder:
.gitignore
.vscode
.vscodeignore
depl.bat
markdown-table-of-contents-0.0.1.vsix
node_modules
out
package-lock.json
package.json
src
tsconfig.json
tslint.json
For me the solution was to run npm install <package_name> (notice no "-g") from the extension's code root folder. Vscode puts the extension in its [extension folder][1], navigate there to do npm install.
Example: for linux/mac
cd ~/.vscode/extensions
cd your.extension
npm install
This automatically added it to the devDependencies as well, and the extension worked perfectly from there on.

Meteor 1.5, johnny-five, serialport connect wrongly

I need help with Meteor 1.5, johnny-five, serialport.
I'm on MacOS. I'm following this guide https://github.com/studiorabota/meteor-johnny-five-tutorial
I made a few changes to the code due to new Meteor version and support NPM.
My NodeJs version v4.6.2
The problem is Meteor connect to the wrong serial port. The following is the error message when I run "meteor":
Available /dev/cu.usbmodem1,/dev/cu.usbserial-A5029U59
Connected /dev/cu.usbmodem1
I need to know how to make Meteor to select the correct port. Please help, thanks in advance.
My Meteor package.json
{
"name": "j5",
"private": true,
"scripts": {
"start": "meteor run"
},
"dependencies": {
"babel-runtime": "^6.20.0",
"johnny-five": "^0.11.1",
"meteor-node-stubs": "~0.2.4",
"serialport": "^4.0.7"
}
}
My server/blink.js
// import johnny-five from 'johnny-five';
var JohnnyFive = require("johnny-five");
Meteor.startup(function(){
board = new JohnnyFive.Board();
board.on('error', function (error) {
console.error('Johnny Five Error', error);
});
board.on("ready", Meteor.bindEnvironment(function() {
var led = new JohnnyFive.Led(13);
led.blink(500);
}, "ready"));
});
You can tell johnny-five which serial port to use:
board = new JohnnyFive.Board({ port : '/dev/cu.usbserial-A5029U59' })
More info here: http://johnny-five.io/api/board/#component-initialization

Categories