Trying to commit after merge, getting errors on git lint - eslint

After performing merge, there is this 1 file that I have to push, after git add ., I run this command
git commit -m "Merge"
This is the output of the command [FAILED] and ✖ are all displaying as red
> company#0.0.0 lint-staged
> lint-staged
[STARTED] Preparing lint-staged...
[SUCCESS] Preparing lint-staged...
[STARTED] Running tasks for staged files...
[STARTED] package.json — 313 files
[STARTED] *.{ts,html} — 238 files
[STARTED] *.scss — 17 files
[STARTED] *.json — 24 files
[STARTED] *.{png,jpeg,jpg,gif,svg} — 19 files
[STARTED] cross-env NODE_OPTIONS=--max_old_space_size=5120 eslint --quiet --cache -…
[STARTED] stylelint --allow-empty-input --cache --cache-location=.cache/stylelint/l…
[STARTED] prettier --write
[STARTED] npm run optimize-images:specific --
[FAILED] cross-env NODE_OPTIONS=--max_old_space_size=5120 eslint --quiet --cache --cache-location=.cache/eslint/lint-staged [FAILED]
[FAILED] cross-env NODE_OPTIONS=--max_old_space_size=5120 eslint --quiet --cache --cache-location=.cache/eslint/lint-staged [FAILED]
[SUCCESS] Running tasks for staged files...
[STARTED] Applying modifications from tasks...
[SKIPPED] Skipped because of errors from tasks.
[STARTED] Reverting to original state because of errors...
[FAILED] prettier --write [KILLED]
[FAILED] prettier --write [KILLED]
[FAILED] npm run optimize-images:specific -- [KILLED]
[FAILED] npm run optimize-images:specific -- [KILLED]
[FAILED] stylelint --allow-empty-input --cache --cache-location=.cache/stylelint/lint-staged [KILLED]
[FAILED] stylelint --allow-empty-input --cache --cache-location=.cache/stylelint/lint-staged [KILLED]
[SUCCESS] Reverting to original state because of errors...
[STARTED] Cleaning up temporary files...
[SUCCESS] Cleaning up temporary files...
✖ cross-env NODE_OPTIONS=--max_old_space_size=5120 eslint --quiet --cache --cache-location=.cache/eslint/lint-staged:
The command line is too long.
✖ prettier --write failed without output (KILLED).
✖ npm run optimize-images:specific -- failed without output (KILLED).
✖ stylelint --allow-empty-input --cache --cache-location=.cache/stylelint/lint-staged failed without output (KILLED).
Normally this wouldn't error, but I'm thinking why it errored out this time...

Related

Lerna build fails on remote - internal packages are badly symlinked

I have a monorepo project created with lerna.
I am trying to create a CI flow to test my repository installation and build actions on a remote environment.
After hitting lerna bootstrap to install all packages dependencies, I am using lerna run build --stream on the root folder which invokes lerna run build for each sub package I have in my repository.
This flow works great on my local machine but fails to work using travis-ci build.
Conclusions so far:
Issue is probably not related to travis-ci service nor to operating system for the reason same behaviour occur on both Ubuntu VM instance on GCP im trying to run the flow on, and on travis-ci server which is configured as a macOS machine.
Neither of bootstrap flags --no-ci, --force-local changes anything.
Navigating to ~/sqpoc/node_modules/#superquery/components/dist suggesting that build files are properly created, meaning issue is probably related to internal lerna symlink flow which fails on the stated environments.
Output:
$ lerna run build --stream
lerna notice cli v4.0.0
lerna info Executing command in 4 packages: "yarn run build"
#superquery/components: $ node ./scripts/build.ts
#superquery/greeter: $ tsc -p tsconfig.release.json && webpack
#superquery/superquery: $ react-scripts build
#superquery/superquery: Creating an optimized production build...
#superquery/greeter: asset bundle.js 39.4 KiB [compared for emit] (name: main)
#superquery/greeter: runtime modules 670 bytes 3 modules
#superquery/greeter: cacheable modules 11.5 KiB
#superquery/greeter: ./build/src/main.js 701 bytes [built] [code generated]
#superquery/greeter: ./node_modules/tslib/tslib.es6.js 10.8 KiB [built] [code generated]
#superquery/greeter: webpack 5.37.0 compiled successfully in 3703 ms
#superquery/server: $ tsc -p tsconfig.release.json
#superquery/superquery: Failed to compile.
#superquery/superquery: ./src/App.tsx
#superquery/superquery: Cannot find module: '#superquery/components'. Make sure this package is installed.
#superquery/superquery: You can install this package by running: yarn add #superquery/components.
#superquery/superquery: error Command failed with exit code 1.
#superquery/superquery: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
lerna ERR! yarn run build exited 1 in '#superquery/superquery'
error Command failed with exit code 1.
Expected output:
$ lerna run build --stream
lerna notice cli v4.0.0
lerna info Executing command in 4 packages: "yarn run build"
#superquery/components: $ node ./scripts/build.ts
#superquery/greeter: $ tsc -p tsconfig.release.json && webpack
#superquery/greeter: asset bundle.js 39.4 KiB [compared for emit] (name: main)
#superquery/greeter: runtime modules 670 bytes 3 modules
#superquery/greeter: cacheable modules 11.5 KiB
#superquery/greeter: ./build/src/main.js 701 bytes [built] [code generated]
#superquery/greeter: ./node_modules/tslib/tslib.es6.js 10.8 KiB [built] [code generated]
#superquery/greeter: webpack 5.37.0 compiled successfully in 1521 ms
#superquery/server: $ tsc -p tsconfig.release.json
#superquery/superquery: $ react-scripts build
#superquery/superquery: Creating an optimized production build...
#superquery/superquery: Compiled successfully.
#superquery/superquery: File sizes after gzip:
#superquery/superquery: 119.52 KB build/static/js/2.ea8fed9a.chunk.js
#superquery/superquery: 4.79 KB build/static/js/main.7a35accd.chunk.js
#superquery/superquery: 1.41 KB build/static/js/3.80a7969b.chunk.js
#superquery/superquery: 1.17 KB build/static/js/runtime-main.d48b464c.js
#superquery/superquery: 574 B build/static/css/main.9d5b29c0.chunk.css
#superquery/superquery: The project was built assuming it is hosted at /.
#superquery/superquery: You can control this with the homepage field in your package.json.
#superquery/superquery: The build folder is ready to be deployed.
#superquery/superquery: You may serve it with a static server:
#superquery/superquery: npm install -g serve
#superquery/superquery: serve -s build
#superquery/superquery: Find out more about deployment here:
#superquery/superquery: https://cra.link/deployment
lerna success run Ran npm script 'build' in 4 packages in 35.9s:
lerna success - #superquery/components
lerna success - #superquery/greeter
lerna success - #superquery/server
lerna success - #superquery/superquery
✨ Done in 37.28s.
package.json file:
{
"name": "superquery",
"version": "1.0.0",
"author": "***************",
"repository": "https://github.com/doitintl/sqpoc.git",
"main": "index.js",
"license": "MIT",
"private": true,
"workspaces": {
"packages": [
"packages/*"
]
},
"scripts": {
"start": "lerna run start --stream",
"test": "lerna run test --stream",
"test:ci": "lerna run test:ci --stream",
"watch": "lerna run watch --stream",
"storybook": "lerna run storybook --stream",
"production": "lerna run production --stream",
"build": "lerna run build --stream",
"deploy": "lerna run deploy --stream",
"bootstrap": "lerna run rimraf && lerna bootstrap",
"rimraf": "rm -rf node_modules",
"installApp": "yarn rimraf && yarn install && yarn bootstrap",
"dev": "lerna run dev",
"dev-logs": "lerna run dev --parallel",
"dev-module": "lerna run dev --scope",
"e2e": "nightwatch -e chrome,firefox",
"e2e-test": "concurrently -k --success first \"npm run start\" \"npm run e2e\""
},
"devDependencies": {
"chromedriver": "^90.0.0",
"geckodriver": "^1.22.3",
"lerna": "^4.0.0",
"selenium-server": "^3.141.59"
}
}
lerna.json file:
{
"useWorkspaces": true,
"npmClient": "yarn",
"version": "1.0.0",
"packages": [
"packages/superquery",
"packages/components"
]
}
Technology stack used:
node 14.17.0
npm 6.14.13
nvm 0.37.2
lerna 4.0.0
yarn 1.22.10
Tried to follow suggestion from below links (and more), it was either naive or irelevant to my issue.
Lerna bootstrap does not link local dependencies?
https://github.com/lerna/lerna/issues/1444
Solved after updating lerna.json file:
{
"useWorkspaces": true,
"npmClient": "yarn",
"version": "1.0.0"
}

Gitlab CI job succeeds before mocha tests are run

I found that my Gitlab jobs are succeeding and ending before the actual test is run.
First, I installing the required dependencies for my app, then I call the mocha commands, but the job succeeds before there is any output from them.
My .gitlab-ci.yml:
image: node:lts-alpine
stages:
- test
test:
stage: test
services:
- mongo:latest
script:
- cd server/
- apk add --update git
- apk --no-cache add g++ gcc libgcc libstdc++ linux-headers make python
- npm install --quiet node-gyp -g
- npm install
- npm rebuild bcrypt --build-from-source
- npm i mocha -g
- mocha ./src/tests/unit/. --timeout 10000 --exit
- mocha ./src/tests/integration/. --timeout 10000 --exit
cache:
key: "$CI_PROJECT_ID"
paths:
- server/node_modules/
And the last couple of lines from the runners output from the console:
...
make: Leaving directory '/builds/myapp/myapp/server/node_modules/bcrypt/build'
bcrypt#3.0.2 /builds/myapp/myapp/server/node_modules/bcrypt
$ npm i mocha -g
/usr/local/bin/mocha -> /usr/local/lib/node_modules/mocha/bin/mocha
/usr/local/bin/_mocha -> /usr/local/lib/node_modules/mocha/bin/_mocha
+ mocha#6.1.4
added 115 packages from 509 contributors in 5.54s
$ mocha ./src/tests/unit/. --timeout 10000 --exit
$ mocha ./src/tests/integration/. --timeout 10000 --exit
Creating cache 8738844...
server/node_modules/: found 19633 matching files
Uploading cache.zip to https://storage.googleapis.com/gitlab-com-runners-cache/project/XXXX/XXXX
Created cache
Job succeeded
my folder structure:
- root
- client/
- server/
public/
src/
tests/
unit/
someUnitTest.js
integration/
someIntegrationTest.js
package.json
...
Why is it not waiting for the commands to start/finish? Locally, they work of course. I also tried using npm run test as an alias for the 2 mocha commands, but it results in the same.
I have found the problem:
The mocha commands are not returning anything because they fail before they start. They have a require('app.js') at the top which starts the server and so on, and due to a missing .env file, this and the mocha tests failed silently.
So properly including a .env file solved the problem.

NPM Run Build Always Builds Production and Never Development

On an inherited project I have, I am trying to get the build command to build a version other than Production.
I have attempted to change the alias in the script section in package.json to pass in extra variables such as --dev and --configuration=dev to no avail.
The project has these json data files:
env.dev
env.development
env.production
with the package.json has this build alias build:dev which I run npm run build:dev:
"scripts": {
"start": "NODE_ENV=dev && react-scripts start",
…
"build:dev": "npm run build --dev --configuration=dev && react-scripts build"
}
This works and builds, but for production only which I verify when I view the resultant files.
If I remove the file env.production from the directory and run the build command, it fails with:
Creating an optimized production build...
Failed to compile.
Module not found: Error: Can't resolve 'polyfills' in 'C:\Work\MyProj\WebSiteName\src'
which just informs me that it can alias polyfills found in the env.production file for the location NODE_PATH=src/.
Thoughts?
you need to set the env. variable like you do in "start" before calling the build command.
"build:dev": "NODE_ENV=dev npm run build --dev --configuration=dev && react-scripts build"

Travis-ci testing node/Vue app , got cross-env: not found

aiming at using Travis-ci for continuous integration , I am processing in my settings... however I get stuck now with this error upon executing package.json scrip test
cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run --browsers ChromeHeadless
sh: 1: cross-env: not found
however, the cross-env package is installed in the dv dependencies
"cross-env": "^5.0.5",
here is the log : Travis build log
Error in travis.yml
should be
install:
- yarn
script:
- yarn test
and not
install:
- yarn test
!! my mistake

When deploying an app to Bluemix using the sdk-for-nodejs buildpack, it's running npm install when I don't want it to. How can I stop it?

I'm using Bluemix DevOps Pipelines to deploy a Node.js app to Bluemix as a Cloud Foundry app. It is using the sdk-for-nodejs buildback (although I haven't specified that, it's detecting the package.json file).
It takes a long time to stage the app. Looking at the logs, this is because it appears to be running npm install. However, I have set up my pipeline so that npm install is called in an earlier stage, and the build artifact that is to be deployed already contains the installed node_modules, so if I have to restage it should be quick, as it shouldn't have to install all the modules again.
This is the command that my pipeline is using to deploy:
cf push "${CF_APP}" -c "npm run start:prod"
My Procfile also contains the same command:
web: npm run start:prod
node: npm run start:prod
(I've tried it both with and without the second line. I think the logs from below were when it contained both lines.)
And indeed towards the end of my deployment logs it says
App mcp-server was started using this command `npm run start:prod`
That script in my package.json file does not run npm install:
"scripts": {
...
"start:prod": "cross-env NODE_ENV=production node index.js",
The logs that make it look like it's re-installing the modules are:
Staging...
-----> IBM SDK for Node.js Buildpack v3.11-20170303-1144
-----> Creating runtime environment
NPM_CONFIG_PRODUCTION=true
NODE_ENV=production
NODE_MODULES_CACHE=true
-----> Installing binaries
engines.npm (package.json): unspecified (use default)
Resolving node version >=4 via 'node-version-resolver'
Installing IBM SDK for Node.js (4.8.0) from cache
Using default npm version: 2.15.11
-----> Restoring cache
Loading 2 from cacheDirectories (default):
- node_modules (exists - skipping)
- bower_components (not cached - skipping)
-----> Building dependencies
Rebuilding any native modules
> radium#0.18.2 postinstall /tmp/app/node_modules/radium
> dtrace-provider#0.8.1 install /tmp/app/node_modules/dtrace-provider
> pre-commit#1.2.2 install /tmp/app/node_modules/pre-commit
> spawn-sync#1.0.15 postinstall /tmp/app/node_modules/spawn-sync
> node postinstall
Completed: 0.1% (0.1mb / 78.2mb)
...
Completed: 99.9% (78.2mb / 78.2mb)
inside extract, run complete
Completed: 0.0% (0.0mb / 78.2mb)
Completed: 0.1% (0.0mb / 78.2mb)
Completed: 2.6% (2.0mb / 78.2mb)
Completed: 8.3% (6.5mb / 78.2mb)
Completed: 43.1% (33.7mb / 78.2mb)
Completed: 44.3% (34.7mb / 78.2mb)
Completed: 45.5% (35.6mb / 78.2mb)
Completed: 64.2% (50.2mb / 78.2mb)
Completed: 65.0% (50.8mb / 78.2mb)
Completed: 66.5% (52.1mb / 78.2mb)
Completed: 71.4% (55.8mb / 78.2mb)
> node-gyp rebuild
make: Entering directory `/tmp/app/node_modules/nodejieba/build'
...
> spawn-sync#1.0.15 postinstall /tmp/app/node_modules/spawn-sync
> npm run clean && npm run build
> myapp#2.0.0 clean /tmp/app
> myapp#2.0.0 build /tmp/app
> cross-env NODE_ENV=production webpack --config webpack.config.js
Of particular note are the lines:
Completed: 0.1% (0.1mb / 78.2mb)
...
Completed: 99.9% (78.2mb / 78.2mb)
where I've omitted well over 100 lines where it seems to be installing something very slowly.
And also:
> npm run clean && npm run build
> myapp#2.0.0 clean /tmp/app
> myapp#2.0.0 build /tmp/app
> cross-env NODE_ENV=production webpack --config webpack.config.js
which are scripts from my app that I really don't want to be running at deployment time.
I've already tried to tell it to run npm run start:prod - how can I stop it from running these install steps?
Looking at the buildpack code, I don't see a flag to disable npm install.
https://github.com/cloudfoundry/nodejs-buildpack/blob/master/lib/dependencies.sh#L80
Option 1
Create a package_nodependencies.json file with no dependencies listed. After your build steps runs the npm install using your regular package.json, delete the package.json and rename package_nodependencies.json to package.json.
rm package.json && mv package_nodependencies.json package.json
npm install on cf push should now be quick. Be sure that you don't have node_modules in your .cfignore file
Option 2
Move all your dependencies to devDependencies in package.json. During your build, run npm install without PRODUCTION
NODE_ENV=development npm install

Resources