I am looking to pass stage argument from npm script to lerna which will call npm script in each of the packages.
Here's what it looks like:
In deploy.sh, I run:
npm run deploy:cicd -- --stage dev
In package.json, I have:
"deploy:cicd": " lerna run deploy --stream",
In each of the packages, the deploy script looks like this:
"deploy": "sls deploy -v",
I need to be able to pass the stage name from deploy.sh so that the deploy command executed in each of the packages will be :
"sls deploy -v --stage dev ",
Currently, I get an error:
> lerna run deploy --stream "-stage" "dev"
ERR! lerna Unknown arguments: p, r, o, f, i, l, e
npm ERR! code 1
npm ERR! path /codebuild/output/src202136904/src
npm ERR! command failed
npm ERR! command sh -c lerna run deploy --stream "-stage" "dev"
In deploy.sh, I tried passing
npm run deploy:cicd -- -- -stage dev
and
npm run deploy:cicd -- -stage dev
and
npm run deploy:cicd -- stage dev
Neither of these has worked for me.
Related
We are building and deploying our Elixir/Phoenix code using Gitlab CI pipe.
Everything was working perfectly fine but today our build log started throwing npm errors and not being able to build the code further
Getting below error in our build logs
#21 1.039 npm ERR! dot-prop not accessible from stylehacks:postcss-selector-parser
852#21 1.044
853#21 1.044 npm ERR! A complete log of this run can be found in:
854#21 1.045 npm ERR! /root/.npm/_logs/2021-12-18T00_00_39_802Z-debug.log
855#21 ERROR: executor failed running [/bin/sh -c npm --prefix ./assets ci --progress=false --no-audit --loglevel=error]: exit code: 1
856------
857 > [build 12/17] RUN npm --prefix ./assets ci --progress=false --no-audit --loglevel=error:
858------
859executor failed running [/bin/sh -c npm --prefix ./assets ci --progress=false --no-audit --loglevel=error]: exit code: 1
860
Cleaning up file based variables
00:01
861ERROR: Job failed: exit code 1
We even tried updating our postcss package but no luck
Any help or pointers is much appreciated.
Able to fix the build issue by modifying the command for npm
Changed code line
From
RUN npm --prefix ./assets ci --progress=false --no-audit --loglevel=error
to
RUN npm --prefix ./assets install --progress=false --no-audit --loglevel=error
I use a bitbucket pipeline to deploy my develop branch.
Everything work fine so far, but now i have an error in the pipeline :
npm install npm ERR! Unexpected token } in JSON at position 803931 while parsing near '...==" npm ERR! } npm ERR! } npm ERR!
} npm ERR! ' npm ERR! A complete log of this run can be found in: npm
ERR! /root/.npm/_logs/2020-11-05T14_19_12_739Z-debug.log
Here is my pipeline script :
image: node:10.15.3
pipelines:
branches:
develop: # develop branch
- step:
deployment: test
caches:
- node
script:
- npm install
- npm install -g #angular/cli
- npm install -g firebase-tools
- ng build
I have 2 repository. One is main, second is dependency package.
In main project in .gitlab-ci.yml I have:
install_dependency:
stage: install-dep
before_script:
- npm config set strict-ssl false
- ls -la
script:
- git config --global http.sslverify false
- npm config set #my-package:registry https://${TOKEN_USERNAME}:${TOKEN_PASSWORD}#HOST/PACKAGE/PACKAGE.git
- npm i git+https://${TOKEN_USERNAME}:${TOKEN_PASSWORD}#HOST/react.git#master
Dependecy have package.json that should install using `npm -i" as dependecy:
package/mypackage: git+https://${TOKEN_USERNAME}:${TOKEN_PASSWORD}#HOST/react.git#master
A problem is that CI did not recognize path:
$ npm i git+https://${TOKEN_USERNAME}:${TOKEN_PASSWORD}#HOST/react.git#master
npm ERR! prepareGitDep 2> npm WARN install Usage of the `--dev` option is deprecated. Use `--only=dev` instead.
npm ERR! prepareGitDep npm WARN tar ENOENT: no such file or directory, open '/root/.npm/_cacache/tmp/git-clone-7b8b3c6a/node_modules/.staging/uglify-js-ce069d2e/lib/compress.js'
Use self-hosted https://verdaccio.org/ to publish NPM package solves that issue.
For publishing into Gitlab it should upgrade Gitlab package (silver ediiton).
I want to call multiple commands with the dev command. I found here that using concurrently is the best way to make this work since this would work on multiple OS.
How can I run multiple npm scripts in parallel?
I rand the folllwing aswell
npm install -g npm-windows-upgrade
npm install -g concurrently
npm install concurrently
I can run them individually. But when I run the script with npm run dev I get the following error. Why can't npm find those commands?
Terminal
[0] 'watch-client' is not recognized as an internal or external command,
[0] operable program or batch file.
[1] 'watch-server' is not recognized as an internal or external command,
[1] operable program or batch file.
[0] watch-client exited with code 1
--> Sending SIGTERM to other processes..
[1] watch-server exited with code 1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! diepio#1.0.0 dev: `concurrently --kill-others "watch-client" "watch-server"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the diepio#1.0.0 dev 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! C:\Users\31614\AppData\Roaming\npm-cache\_logs\2019-12-24T11_09_40_394Z-debug.log
Package.json
"scripts": {
"dev": "concurrently --kill-others \"watch-client\" \"watch-server\" \"serve\"",
"watch-client": "parcel ./src/client/index.html --open --out-dir ./builds/development/public",
"watch-server": "parcel ./src/server/index.ts --out-dir ./builds/development/private --target node",
"serve": "nodemon ./builds/development/private"
}
You may need to add npm and its submodules into your system PATH.
Have you downloaded the npm modules into your project directory?
You could also check that you have installed your npm submodules with the global argument.
The problem was that I was running the scripts in the wrong way I had to do it like this "dev": "concurrently --kill-others \"npm run watch-client\" \"npm run watch-server\" \"npm run serve\"",
I try to build a project on macOS but the build fails.
I have in my package.json:
"scripts": {
...
"build": "build",
...
when I run npm run build I get the following error:
sh: build: command not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! project build: `build`
npm ERR! spawn ENOENT
There is file in the same folder that that is called "build", when I go there and execute the commands manually everything works fine. What could be the cause?
Given that you have set the execute permissions for the build script, you should be able to run it if you set up the build command like this:
"build": "./build"
I execute a php-based shell script to copy a reactjs file into a blade template (for Laravel) this way:
1 - inside my package.json
"production": "npx webpack --mode production && npm run rjs",
"rjs": "php sh_rjsToView.php",
2 - my php script I want to run directly after building my react-compiled stuff is located in the root of my project directory:
sh_rjsToView.php
3 - I'm not sure if it is absolutely necessary in this context, but remember to give execute permissions to the php script just above, so do this before you run it from package.json the first time:
chmod ug+x sh_rjsToView.php
4 - now run the whole thing:
npm run production