pnpm giving error sh: rimraf: command not found - pnpm

I have just started using pnpm thanks to this cool template https://github.com/NiGhTTraX/ts-monorepo
and at one point, I cleaned all node_module folders with the command
find . -name "node_modules" | xargs rm -rf
Now when I run pnpm install && pnpm run build, I get the following output about rimraf not being found :(
dean#Deans-MacBook-Pro typescript % pnpm run build
> ts-monorepo# build /Users/dean/workspace/gazehealth/gazehealth/typescript
> lerna run build
lerna notice cli v4.0.0
lerna info versioning independent
lerna info Executing command in 9 packages: "pnpm run build"
lerna ERR! pnpm run build exited 1 in '#nighttrax/apiUsers'
lerna ERR! pnpm run build stdout:
> #nighttrax/apiUsers#1.0.0 build /Users/dean/workspace/gazehealth/gazehealth/typescript/libraries/apiUsers
> pnpm run clean && pnpm run compile
> #nighttrax/apiUsers#1.0.0 clean /Users/dean/workspace/gazehealth/gazehealth/typescript/libraries/apiUsers
> rimraf -rf ./dist
ERROR  Command failed.
ERROR  Command failed with exit code 1.
lerna ERR! pnpm run build stderr:
sh: rimraf: command not found
lerna ERR! pnpm run build exited 1 in '#nighttrax/apiUsers'
lerna WARN complete Waiting for 1 child process to exit. CTRL-C to exit immediately.
ERROR  Command failed with exit code 1.
How to fix this? Ideally 'not' with a global install so other developers systems will work when they git clone the repo (ideally developers should not have to install stuff much like gradle & it's gradle wrapper did for java)

Related

Npm can be found but using "npm run something" gives the "npm is not recognized" error

I'm using git bash that was installed with the git for windows bundle, and this is what I have:
where node
C:\Program Files\nodejs\node.exe
where npm
C:\Program Files\nodejs\npm
C:\Program Files\nodejs\npm.cmd
But running any npm run * related script tells me that npm can't be found. Not sure what is wrong with the setup, as the paths seem right and "where" can find them. I can execute npm and node from this git bash (for example I can run node -v and npm -v) but I can't run any script.
I tried reinstalling both node and git bash but it didn't have any effect.
Any idea what could be wrong?

yarn dev error Command failed with exit code 1 when running guest-book example

I'm trying to use yarn dev to run the guest-book example following the guest-book example, but this is what I got:
Computer#Summerbook MINGW64 ~/Documents/VS Code Projects/near apps/guest-book (master)
$ yarn dev
yarn run v1.22.11
$ yarn build:contract:debug && near dev-deploy && nodemon --watch assembly -e ts --exec yarn dev:start
$ asb --target debug
'asb' is not recognized as an internal or external command,
operable program or batch file.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
I think the error is this:
'asb' is not recognized as an internal or external command,
operable program or batch file.
The script in package.json is:
"scripts": {
"build": "yarn build:contract && yarn build:web",
"build:contract": "asb",
"build:contract:debug": "asb --target debug",
"build:web": "parcel build src/index.html --public-url ./",
"deploy": "yarn build && near deploy && gh-pages -d dist/",
"dev": "yarn build:contract:debug && near dev-deploy && nodemon --watch assembly -e ts --exec yarn dev:start",
"lint": "eslint \"./**/*.js\" \"./**/*.jsx\"",
"start": "yarn deploy && parcel src/index.html",
"dev:start": "env-cmd -f ./neardev/dev-account.env parcel src/index.html",
"test": "yarn build:contract:debug && asp && jest"
I've tried installing dependencies again, but it didn't work.
I believe I'm running under the same directory as package.json.
What can I do here? What causes the error with 'asb'? Thanks for any help!
Moving my answer from the comment:
yarn and then yarn dev should just work. Try using regular Windows terminal (cmd or powershell).
Your VS code seems to use mingw (bash for Windows) environment, which brings its own set of quirks. You may want to switch your default terminal in VS code back to cmd or powershell.
Please try sudo npm install -g asbuild.
Feel free to +1 on https://github.com/near-examples/guest-book/issues/543
It seems that the update to the sdk was never merged with the example. I updated it here: https://github.com/near-examples/guest-book/pull/539#pullrequestreview-721177317
Please try again and let me know if the issue is fixed. Thanks!

Enoent rename error in NPM through docker

I have a CI script to compile a nativescript mobile application that runs in a docker container.
When I try to run it, I get the following error:
npm ERR! code ENOENT
npm ERR! syscall rename
npm ERR! path /app/node_modules/.staging/proxy-lib-1731e398
npm ERR! dest /app/node_modules/nativescript/node_modules/proxy-lib
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, rename '/app/node_modules/.staging/proxy-lib-1731e398' -> '/app/node_modules/nativescript/node_modules/proxy-lib'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /.npm/_logs/2020-02-20T10_15_12_334Z-debug.log
Could not update the project! Reason is: Command npm failed with exit code 254
From what I have been able to establish, this seems to be a NPM related issue, regarding permissions.
The strange thing is that the behaviour is only showing up when used through docker.
Compiling the application on my host works, but when I do so in a docker container in the same host, I get this error.
I have messed a lot with the permissions of the npm related folders, as I have witnessed a similar issue in the past, but now I don't seem to be able to get this to work.
Regarding docker and permissions, this is what I have set at the moment:
# fix for docker npm permissions
RUN mkdir -p /.npm
RUN chown -R $DOCKER_USER:$DOCKER_GROUP /.npm
# fix for docker npm permissions
RUN mkdir -p /.config
RUN chown -R $DOCKER_USER:$DOCKER_GROUP /.config
# fix for docker npm permissions
RUN mkdir -p /root/.npm
RUN chown -R $DOCKER_USER:$DOCKER_GROUP /root/.npm
# fix for docker npm permissions
RUN mkdir -p /root/.config
RUN chown -R $DOCKER_USER:$DOCKER_GROUP /root/.config
# needed for npm install and nativescript install
RUN mkdir -p $NVM_DIR/versions/node/v$NODE_VERSION/lib/node_modules
RUN chown -R $DOCKER_USER:$DOCKER_GROUP $NVM_DIR/versions/node/v$NODE_VERSION/
# needed for nativescript install
RUN mkdir -p /.local
RUN chown -R $DOCKER_USER:$DOCKER_GROUP /.local
# change owner of android sdk
RUN chown -R $DOCKER_USER:$DOCKER_GROUP $ANDROID_HOME
# change owner of android local settings folder
RUN mkdir -p /.android
RUN touch /.android/repositories.cfg
RUN chown -R $DOCKER_USER:$DOCKER_GROUP /.android
# change owner of android local settings folder
RUN mkdir -p /.gradle
RUN chown -R $DOCKER_USER:$DOCKER_GROUP /.gradle
# change owner of crashlytics local settings folder
RUN mkdir -p /.crashlytics
RUN chown -R $DOCKER_USER:$DOCKER_GROUP /.crashlytics
The docker user and group variables are 106 and 112 respectively.
NPM version is 6.13.4
Node version is v12.14.0
** UPDATE **
Based on the comment left by David Maze, I am leaving here some additional information:
I am running a docker container using the below command, and only mapping the volume regarding the folder in the host that contains the source. One of the first step of the builds is deleting completely the node modules folder, as well as cleaning the cache.
Docker command:
docker run -it -v my_host_folder:/app alfasoft/node-nativescript:0.17 bash
After that, and inside the docker container, I am running all the steps I had in my Jenkinsfile (su to jenkins user, change to bash and then run all of this):
rm -rf node_modules
source /usr/local/nvm/nvm.sh
nvm use default
echo "Clearing NPM Cache"
npm cache clear --force
echo "Running NPM Install"
npm install
echo "Install angular devkit"
npm install --save --unsafe-perm #angular-devkit/build-angular
echo "Installing Nativescript"
npm install -g nativescript
echo "Installing TNS"
tns install
echo "TNS doctor"
tns doctor
echo "TNS platform remove android"
tns platform remove android
echo "TNS platform add android"
tns platform add android
echo "TNS update"
tns update
echo "build android"
tns build android --hmr --env.prod --clean --env.snapshot --env.uglify
Any hint on why this might be happening?

How to build Botframework-WebChat v4

Sorry for asking this, but how can i build the botframework-webchat v4.5.2? I ran 'npm run bootstrap' and 'npm run build'. Both commands exited successfully, but i can't find the webchat.js file.
You need to run npm run build:sample when you are first getting started. Then the normal build and watch commands should build the webchat.js files from then on. Not sure if this is documented anywhere.
npm install
npm run bootstrap
npm run build:sample
npm run build
To run the test harness run npm run start:docker and wait for the command to finish - it should take awhile for docker container to build. Then in another terminal run npm test.
Hope this helps!

GitLab runner only executing one command

I have the following configuration in .gitlab-ci.yml:
stages:
- build
build:
stage: build
script:
- npm install -g gulp
- npm install
- gulp
But the runner is only executing the first command (npm install -g gulp). It runs the first command and reports success, without executing the others.
The build log:
Running with gitlab-ci-multi-runner 1.6.1 (c52ad4f)
Using Shell executor...
Running on WINBUILDER...
Fetching changes...
HEAD is now at 2df18c5 Update .gitlab-ci.yml
From https://.../client
2df18c5..b4efae8 master -> origin/master
Checking out b4efae85 as master...
$ npm install -g gulp
C:\Users\Administrator\AppData\Roaming\npm\gulp -> C:\Users\Administrator\AppData\Roaming\npm\node_modules\gulp\bin\gulp.js
C:\Users\Administrator\AppData\Roaming\npm
`-- gulp#3.9.1
Build succeeded
I've seen several config examples using multiple commands in a stage. I don't understand why the other commands are not running.
It's actually an NPM bug as described here:
https://github.com/npm/npm/issues/2938
NPM closes the shell upon exit and subsequent commands are not called.
A workaround is described in the issue above. Just add a call command before calling NPM:
stages:
- build
build:
stage: build
script:
- call npm install -g gulp
- call npm install
- gulp

Resources