AssemblyScript on NEAR: `/bin/sh: asb: command not found` when deploying Guest Book with yarn - nearprotocol

When running the GuestBook example on NEAR using yarn deploy the following error is produced:
/bin/sh: asb: command not found
This appears to be happening to people using the Figment Learn NEAR path as well, based on Discord conversations.
Running
npm install asb
returns
npm WARN ERESOLVE overriding peer dependency
npm WARN Found: assemblyscript#0.17.14
npm WARN node_modules/assemblyscript
npm WARN assemblyscript#"^0.17.3" from near-sdk-core#2.2.4
npm WARN node_modules/near-sdk-core
npm WARN near-sdk-core#"^2.2.4" from near-sdk-as#2.2.4
npm WARN node_modules/near-sdk-as
npm WARN 1 more (#as-pect/cli)
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer assemblyscript#"^0.13.3" from visitor-as#0.3.2
npm WARN node_modules/visitor-as
npm WARN visitor-as#"^0.3.2" from near-sdk-core#2.2.4
npm WARN node_modules/near-sdk-core
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/asb - Not found
npm ERR! 404
npm ERR! 404 'asb#*' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
Edit:
Many yarn install and yarn update commands later, the error seems to have migrated to a missing asc library:
$ asb
node:internal/modules/cjs/loader:926
throw err;
^
Error: Cannot find module 'assemblyscript/cli/asc'

You are correct the asb command is short for asbuild (which is another alias command), which is a dependency of near-sdk-as and should be installed with yarn or yarn install.
asc, installed as assemblyscript, should also be present because it is a dependency of near-sdk-as. So it not being found is suspicious. My guesses are:
You need to run yarn first to install everything.
Somehow NODE_ENV was set to be "production", which then causes yarn to install only dependencies and not devDependencies. To fix this unset it with NODE_ENV= or export NODE_ENV=. Then run yarn again.
My one complaint with npm and yarn is that you need to have an install step. Rust's cargo installs dependencies as needed.

I had a similar issue and I fixed it by login first to running yarn.
step 1: run near login and connect your wallet (testnet or mainnet for instance)
step 2: run yarn to install all dependencies.
This should works... greetings!

In my case too, I was constantly getting this error no matter what I did;
asb: command not found
While I was just giving up hope, this command was my solution.
yarn add -D near-sdk-as

Related

In terminal 'tns preview' command not working. (NativeScript)

I wanted to run my NS application in local. I downloaded project from play.nativescript.org, And I open cmd with target path and I followed this steps
Step 1. Install the latest NativeScript CLI
Type the following command in a Command Prompt or Terminal.
npm install -g nativescript#latest
and I have successfully installed the NativeScript CLI
Step 2. Preview your app
Navigate to your project folder and run the following command to start
previewing your app.
tns preview
When I entered the command I get this errors
You are using the deprecated nsconfig.json file. Just be aware that NativeScript 7 has an improved nativescript.config.(js|ts) file for when you're ready to upgrade this project.
npm WARN deprecated bfj-node4#5.3.1: Switch to the `bfj` package for fixes and new features!
npm WARN deprecated request#2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated request#2.88.0: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated core-js#2.6.11: core-js#<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js#3.
npm WARN deprecated har-validator#5.1.5: this library is no longer supported
npm WARN deprecated urix#0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated chokidar#2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated fsevents#1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
npm WARN deprecated resolve-url#0.2.1: https://github.com/lydell/resolve-url#deprecated
npm ERR! code E404
npm ERR! 404 Not Found - GET https://github.com/thomasconner/javascript/tarball/67b7944366453a87226389d483ac1ad861e0e129npm ERR! 404
npm ERR! 404 'pubnub#https://github.com/thomasconner/javascript/tarball/67b7944366453a87226389d483ac1ad861e0e129' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 It was specified as a dependency of 'kinvey-nativescript-sdk'
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\dotor\AppData\Roaming\npm-cache\_logs\2020-10-01T09_47_56_177Z-debug.log
Command npm.cmd failed with exit code 1
As in github.com therosko has written, making kinvey-nativescript-sdk version as 5.0.1 worked for me. Src: here
Unfortunately, play.nativescript.org exported projects won't run with nativescript version 7 and up.
Currently, the only solution would be to install {N} CLI using npm install -g nativescript#6.8.0

Install NPM package if not installed using shell script

I want to write a shell script to install NPM package if not already installed.
I can use the command npm info <package-name> version to get information about the package. It gives me the version if it is already there
2.0.0
If it is not there it gives an error.
npm ERR! code E404
npm ERR! 404 Not found :<package>
npm ERR! 404
npm ERR! 404 '<package>' is not in the npm registry.
How can I use this result in a conditional block to do some task depending on it?
I think you're over-complicating things. npm-install already checks if the module is installed and just ignores it if it's already there, so all you need to do is call it:
$ npm install mymodule#2.0.0

Composer runtime (0.18.2) is not compatible with client (0.17.6)

I am trying to run composer-sample-applicaions(Digital Property) but when I am trying to run npm test it is throwing an error: Composer runtime (0.18.2) is not compatible with the client (0.17.6)
Following is the complete log:
paradox#labrats:~/hyperledger/composer/github/composer-sample-applications/packages/digitalproperty-app$ npm test
> digitalproperty-app#0.0.7 test /home/paradox/hyperledger/composer/github/composer-sample-applications/packages/digitalproperty-app
> npm run bootstrapAssets && npm run listAssets && npm run submitTransaction
> digitalproperty-app#0.0.7 bootstrapAssets /home/paradox/hyperledger/composer/github/composer-sample-applications/packages/digitalproperty-app
> node cli.js landregistry bootstrap
info: [DigitalProperty-App] Hyperledger Composer: Digital Property console application
info: [DigitalProperty-App] Adding default land titles to the asset registry
error: [DigitalProperty-App] Error: Error trying to ping. Error: Composer runtime (0.18.2) is not compatible with client (0.17.6)
Command failed.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! digitalproperty-app#0.0.7 bootstrapAssets: `node cli.js landregistry bootstrap`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the digitalproperty-app#0.0.7 bootstrapAssets script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/paradox/.npm/_logs/2018-03-26T09_35_58_193Z-debug.log
npm ERR! Test failed. See above for more details.
paradox#labrats:~/hyperledger/composer/github/composer-sample-applications/packages/digitalproperty-app$
Any lead would be appreciated
The runtime refers to the version of Composer that is installed on to the Peer with your Network - you can see this if you execute docker ps -a and you will see a container with a name such as dev-peer0.org1.example.com-animaltracking-network-0.16.6... this shows the Composer runtime version and the network name.
You have a couple of options:
Re-create your Fabric which will delete that container with the 18.2 runtime
Upgrade your client to 18.2
Different versions of Composer need different versions of Fabric - checkout this document which covers releases of Composer with their supported Fabric versions.
Composer runtime and client must be on same version.
Best approach to solve this issue, execute following commands in order.
npm install -g composer-cli
npm install -g composer-rest-server

Error installing Composer on Ubuntu

I am trying to install Composer on Ubuntu 14.04. I was able to install the prerequisites. When installing composer, I get the following error. How to fix it?
npm install -g composer-cli
npm WARN deprecated fs-promise#1.0.0: Use mz or fs-extra^3.0 with Promise Support
npm WARN deprecated crypto#0.0.3: This package is no longer supported. It's now a built-in Node module. If you've depended on crypto, you should switch to the one that's built-in.
npm WARN deprecated node-uuid#1.4.8: Use uuid module instead
npm WARN deprecated jade#1.11.0: Jade has been renamed to pug, please install the latest version of pug instead of jade
npm WARN deprecated transformers#2.1.0: Deprecated, use jstransformer
npm WARN deprecated nodemailer#2.7.2: All versions below 4.0.1 of Nodemailer are deprecated. See https://nodemailer.com/status/
/root/.nvm/versions/node/v6.11.2/bin/composer -> /root/.nvm/versions/node/v6.11.2/lib/node_modules/composer-cli/cli.js
> hashtable#2.0.2 install /root/.nvm/versions/node/v6.11.2/lib/node_modules/composer-cli/node_modules/hashtable
> node-gyp configure build
sh: 1: node-gyp: Permission denied
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.1.2 (node_modules/composer-cli/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! hashtable#2.0.2 install: `node-gyp configure build`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the hashtable#2.0.2 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2017-08-22T16_31_22_412Z-debug.log
So firstly you should not install Hyperledger Composer as 'root'. You need to read the docs here before you proceed https://hyperledger.github.io/composer/installing/development-tools.html
So fundamentally this is an npm issue (in that it causes problems for npm, when you npm install as 'root' or 'sudo' privileges for installing modules).
I suggest you create a non-root user in your Ubuntu system. Then log in as that user. Then install the pre-reqs using the supplied prereqs-ubuntu.sh script from the link above. Then follow the instructions, installing as your non-privileged user.
Normal route to fixing a non-root install npm issue, is one of these shown here https://docs.npmjs.com/getting-started/fixing-npm-permissions
When you install composer modules globally (eg. composer-cli) you should install using a designated, non-root user as mentioned. If there are issues (eg, on Ubuntu with permissions to write/update node directories located in system directories like /usr/local) - one solution (but see link earlier) is perform the npm install to a directory you have access to - rather than resort to root or superuser access, as this is not good practice. Here is what to do to set the npm prefix to a given directory, ...
"npm config set prefix /home/myuser/"
In this case, global binaries are placed in /home/myuser/bin which is in your PATH, and the modules are placed in /home/myuser/lib ...

Unable to run heroku-cli commands - issues with npm

When trying to run heroku fork on Mac OS X Yosemite, I all the sudden am running into critical errors that render the CLI useless. This problem did not occur previously and I believe the CLI may have updated itself and started causing problems.
~ ☽ heroku fork -a oldapp newapp
Installing plugin heroku-fork... npm ERR! Darwin 14.0.0
npm ERR! argv "/Users/Me/.heroku/iojs-v2.0.0-darwin-x64/bin/iojs" "/Users/JJ/.heroku/iojs-v2.0.0-darwin-x64/lib/node_modules/npm/cli.js" "install" "heroku-fork"
npm ERR! node v2.0.0
npm ERR! npm v2.9.0
npm ERR! code ETARGET
npm ERR! notarget No compatible version found: heroku-cli-util#'>=1.9.0 <2.0.0'
npm ERR! notarget Valid install targets:
npm ERR! notarget ["1.0.0","1.0.1","1.1.0","1.2.0","1.3.0","1.4.0","1.5.0","1.7.0","1.8.0","1.8.1"]
npm ERR! notarget
npm ERR! notarget This is most likely not a problem with npm itself.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! notarget
npm ERR! notarget It was specified as a dependency of 'heroku-fork'
npm ERR! notarget
npm ERR! Please include the following file with any support request:
npm ERR! /Users/Me/.heroku/npm-debug.log
ERROR: exit status 1
Usage: heroku COMMAND [--app APP] [command-specific-options]
Help topics, type "heroku help TOPIC" for more details:
heroku version # print the version
heroku plugins # manage plugins
heroku update # update heroku-cli
I've tried removing and reinstalling the heroku cli via: homebrew, the official installer, even the rubygem. Since the error seems to suggest there's an npm problem, I updated npm and all of my npm packages, and was even able to explicitly run npm install -g heroku-cli-util#1.10.0 but none of that has made any difference.
What is going wrong here/how can I fix this? This is a critical issue for me.
I think the cache got stuck somehow, try deleting ~/.heroku and trying again.
EDIT: turns out this was an issue with caching on the Heroku private npm server.

Resources