Keystone.js app startup fails on Heroku due to missing importer? - heroku

My Keystone.js 4 project using Node 10.15 is failing to start on Heroku:
Error: Cannot find module './lib/core/importer'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (/app/node_modules/keystone/index.js:6:16)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
Process exited with status 1
State changed from crashed to starting
Starting process with command `node ./dist/keystone.js`
State changed from starting to crashed
Process exited with status 1
internal/modules/cjs/loader.js:583
throw err;
I have other Keystone applications configured in exactly the same way that run correctly.
I have tried disabling the build cache, creating a new application instance to deploy to and have verified through the Heroku console that the file in question does exist in the source.
The project builds and runs correctly in Windows 10 and *nix environments locally.
What can I do to debug this?

So it seems the problem is due to npm 6.5.x not installing all of Keystone's dependencies. Switching to Yarn as the package manager fixes this.
I installed the latest version of Yarn, 1.13.0 as of now.
Installed dependencies via yarn
Committed the yarn.lock file
Specified "yarn": "1.13.0" in the "engines" section of my package.json and removed "npm" from the engines.
Re-deployed to Heroku and it works as expected.
Hope this helps someone!

Related

Getting error when trying to run Ganache (forking BSC chain)

I have installed Ganache following instructions from https://github.com/trufflesuite/ganache#documentation
I am trying to fork BSC chain for which I have a node running locally which is fully synced (I want to fork this for which I have provided the URL in package.json under scripts).
When trying to run Ganache using npm run ganache it is giving me this error. Any idea how can I solve this?
SyntaxError: Unexpected token '?'
at wrapSafe (internal/modules/cjs/loader.js:915:16)
at Module._compile (internal/modules/cjs/loader.js:963:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.__webpack_require__.f.require (/usr/local/lib/node_modules/ganache/dist/node/cli.js:2:21481)
at /usr/local/lib/node_modules/ganache/dist/node/cli.js:2:20777
at Array.reduce (<anonymous>)`
Supposedly it was supposed to run after this, so why i am getting this error?
Check your Node.js version:
node -v
v18.13.0
Version must be >= v14.0.0. After updating to the latest Node.js version, the error no longer occurred for me.

Error when run substrate-front-end-template$ yarn install

I have been following the instruction to Install the Front-end template , error when I run substrate-front-end-template$ yarn install.The error is following:
Error: Cannot find module 'worker_threads'
## Heading ##at Function.Module._resolveFilename (internal/modules cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at /home/erichuang2005/substrate-node-template/substrate-front-end-template/.yarn/releases/yarn-berry.cjs:289:2658
I'm not sure about your exact error message but I also had a problem with yarn install which was solved by using a different version of node. I had a problem with version 17. Version 16 worked for me.

composer rest server fails to start after upgrade to composer 0.19.6

docker logs -f rest shows the following
[2018-05-28 06:38:39] PM2 log: Launching in no daemon mode
[2018-05-28 06:38:39] PM2 log: Starting execution sequence in -fork mode- for app name:composer-rest-server id:0
[2018-05-28 06:38:39] PM2 log: App name:composer-rest-server id:0 online
{ Error: Cannot find module 'base64-js'
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> (/home/composer/node_modules/swagger-client/dist/index.js:7:11309)
at t (/home/composer/node_modules/swagger-client/dist/index.js:1:177)
at Object.<anonymous> (/home/composer/node_modules/swagger-client/dist/index.js:7:7)
at Object.<anonymous> (/home/composer/node_modules/swagger-client/dist/index.js:7:11111)
at t (/home/composer/node_modules/swagger-client/dist/index.js:1:177)
at Object.<anonymous> (/home/composer/node_modules/swagger-client/dist/index.js:1:48717)
at t (/home/composer/node_modules/swagger-client/dist/index.js:1:177)
at Object.<anonymous> (/home/composer/node_modules/swagger-client/dist/index.js:1:40420)
at t (/home/composer/node_modules/swagger-client/dist/index.js:1:177)
at Object.<anonymous> (/home/composer/node_modules/swagger-client/dist/index.js:1:16408)
at t (/home/composer/node_modules/swagger-client/dist/index.js:1:177)
at Object.<anonymous> (/home/composer/node_modules/swagger-client/dist/index.js:1:15877) code: 'MODULE_NOT_FOUND' }
[2018-05-28 06:38:41] PM2 log: App [composer-rest-server] with id [0] and pid [14], exited with code [1] via signal [SIGINT]
I installed base64-js via npm but still get the same error
Following on from the previous answer and comments:
There has been a problem last week building the Docker Images for Composer, so the version with the "latest" tag is v0.19.5.
If you look at this page on Docker Hub you can see the problem:
https://hub.docker.com/r/hyperledger/composer-rest-server/tags/
As a temporary measure, if you run these 2 docker commands you should get a v0.19.6 version of the image that will be compatible with your v0.19.6 installed modules.
docker pull hyperledger/composer-rest-server:0.19.6-20180524041020
docker tag hyperledger/composer-rest-server:0.19.6-20180524041020 hyperledger/composer-rest-server:latest
I would suggest using docker rmi to remove any existing composer-rest-server images before using the commands above.
UPDATE After Later Comments - AND Appology
I'm sorry - I thought this would work and that these versions would be compatible.
To get compatibility now, you could re-install everything to v0.19.5 and use the 'trick' above to pull a composer-rest-server v0.19.5 and rename to latest (having removed the earlier one first)
or
you could uninstall composer and install the date specific version to be compatible with the container version. (you will need to restart fabric and re-deploy the network again.) e.g. npm install -g composer-cli#0.19.6-20180524041020
I have not tested this!
see https://github.com/hyperledger/composer/issues/4067
A bad swagger-client npm module was published 3 days ago which caused the problem. A new version of swagger-client 3.8.6 has now been published to fix the problem.

Modify Kibana Source Code for Pie Charts

We are Exploring possibilities to extend and modify Kibana. I am trying to customize the existing Pie Chart functionality by forking kibana and then adding some consoles and eventually add customizations in Pie_chart.js in src/cli/public/vislib/visualizations. When I do ./kibana from bin in my local branch of kibana it gives me an error
/Users/schhatre/kibanSourceRepo/kibana/src/optimize/babel_options.js:4
let cloneDeep = require('lodash').cloneDeep;
^^^^^^^^^
SyntaxError: Unexpected identifier
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 Object.<anonymous> (/Users/schhatre/kibanSourceRepo/kibana/src/cli/index.js:3:22)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
My forked Kibana is https://github.com/schhatre/kibana. I also removed 'Use Strict' since it was giving me Keyword 'Word' errors earlier when I run ./kibana
Eventually I would like to start kibana by modifying kibana.yml with my IP and see my consoles and eventually move on to customize the Pie Charts.
I was successfully able to start Kibana and implement some plugins (Since plugins can be added in src/plugins and don't need Kibana Source code Changes) from downloaded zip but not from the github forked/cloned master branch's bin location.
Any help would be appreciated.I even went to an older 4.4 Version our company is on and tried to run ./kiban from /bin. Still no luck..
Swaraj
It seems that your NodeJs version does not support ES2015 syntax. Make sure that you are using the proper version. To get the required NodeJs version:
cat .node-version
(your version is 4.4.4 on your repository)
Install this version with NVM (install NVM first if you don't have it):
nvm install v4.4.4
Use the version you just installed :
nvm use v4.4.4
Start Kibana:
npm start

Cordova 4.3.0 - build command returns error Cannot find module 'Q'

After updating cordova to version 4.3.0 the command:
cordova build
returns the following error:
module.js:340
throw err;
^
Error: Cannot find module 'Q'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/Volumes/CaseSensitive/ios_projects/_Tests/testGruntCordova/testGruntCordova/platforms/ios/cordova/lib/check_reqs.js:25:13)
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 Module.require (module.js:364:17)
ERROR building one of the platforms: Error: /Volumes/CaseSensitive/ios_projects/_Tests/testGruntCordova/testGruntCordova/platforms/ios/cordova/build: Command failed with exit code 8
You may not have the required environment or OS to build this project
Error: /Volumes/CaseSensitive/ios_projects/_Tests/testGruntCordova/testGruntCordova/platforms/ios/cordova/build: Command failed with exit code 8
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:753:16)
at Process.ChildProcess._handle.onexit (child_process.js:820:5)
I have already tried to remove and add the platform ios but nothing changes.
I have tried to run:
sudo npm install -g cordova / sudo npm install cordova
sudo npm install -g Q / sudo npm install Q
but nothing changes.
Any help?
Thank you very much
There was a bug and I have released a patch to it:
Apache Cordova ios - Git Repository
This is a bug shown on case-sensitive systems such as Unix, Linux and some OS X (if set as case-sensitive).
So far, to fix it, you have to locate those files containing a line like this:
Q = require('Q')
You can locate the files while standing on your project directory using grep:
grep -HnrI "require('Q" *;
then, use any text editor to manually change the mentioned line to:
Q = require('q')
Alternatively you can edit the related files on a more straight forward way by running the following command on your project directory:
grep -rl "require('Q" * | xargs sed -i "" "s/'Q'/'q'/g";
The single line above searches and edits the files that need the change.
Removing and then re-adding the platform again also works:
cordova platform remove ios
cordova platform add ios
Now you can cordova build ios :)
As mentioned by MeV this was a bug.

Resources