Appveyor - Cannot find module 'canvas' - node.js

My dev machines (Ubuntu & Windows) do build and test https://github.com/Codeuctivity/PdfjsSharp without any problem, but Appveyor complains while testing that there is a dependency missing:
Error: Cannot find module 'canvas'
The build logs a succesfull install of canvas:
> canvas#2.6.1 install C:\projects\pdfjssharp\PdfjsSharp\node_modules\canvas
> node-pre-gyp install --fallback-to-build
node-pre-gyp WARN Using needle for node-pre-gyp https download
[canvas] Success: "C:\projects\pdfjssharp\PdfjsSharp\node_modules\canvas\build\Release\canvas.node" is installed via remote
added 100 packages from 50 contributors and audited 100 packages in 6.246s
18 packages are looking for funding
What do I miss here? Seems like there is some appveyor specific issue here, isnt it?

Switched over to Travis CI using that .travis.yml
language: csharp
mono: none
dotnet: 3.1.401
script:
- dotnet restore
- dotnet build -c Release
after_success:
- dotnet test
deploy:
skip_cleanup: true
provider: script
script: dotnet nuget push ./PdfjsSharp/bin/Release/PdfjsSharp.*.*nupkg -k $NUGET_API -s https://api.nuget.org/v3/index.json
on:
branch: master

Related

Anyone else getting this error? .... Error: std::bad_alloc ... ERROR: job failed exit code 1 deploying Gatsby site

I am new to gatsby and not sure why I am getting this error :
Error: std::bad_alloc ... ERROR: job failed exit code 1. It occurs after the command gatsby build is executed..
**Here is my gitlab-ci.yml (in Visual Studio)
**
`stages: # List of stages for jobs, and their order of execution
- build
- test
- deploy
build-website: # This job runs in the build stage, which runs first.
stage: build
image: node:latest
script:
- echo "Compiling the code..."
- npm install
- npm install -g gatsby-cli
- gatsby build --verbose
artifacts:
paths:
- public
- echo "Compile complete."
unit-test-job: # This job runs in the test stage.
stage: test # It only starts when the job in the build stage completes successfully.
script:
- echo "Running unit tests... This will take about 60 seconds."
- sleep 60
- echo "Code coverage is 90%"
lint-test-job: # This job also runs in the test stage.
stage: test # It can run at the same time as unit-test-job (in parallel).
script:
- echo "Linting code... This will take about 10 seconds."
- sleep 10
- echo "No lint issues found."
deploy-job: # This job runs in the deploy stage.
stage: deploy # It only runs when *both* jobs in the test stage complete successfully.
environment: production
script:
- echo "Deploying application..."
- echo "Application successfully deployed."
**Here is the output and Error: **
`Running with gitlab-runner 15.7.1 (6d480948)
on TODDs-iMac.local 2swxxWzH
Preparing the "docker" executor
00:02
Using Docker executor with image node:latest ...
Pulling docker image node:latest ...
Using docker image sha256:548714e444f4d0c77d9a6bd243b10715663c73425b28ca648a224f5e31510882 for node:latest with digest node#sha256:d5222e1ebd7dd7e9683f47a8861a4711cb4407a4830cbe04a582ca4986245700 ...
Preparing environment
00:01
Running on runner-2swxxwzh-project-41617098-concurrent-0 via TODDs-iMac.local...
Getting source from Git repository
00:05
Fetching changes with git depth set to 20...
Reinitialized existing Git repository in /builds/Toddrickson/my-static-website/.git/
Checking out a69c6eb5 as main...
Removing .cache/compiled/
Removing node_modules/.bin/ansi-html
Removing node_modules/#lmdb/lmdb-linux-x64/
Removing node_modules/#msgpackr-extract/msgpackr-extract-linux-x64/
Removing node_modules/#parcel/cache/node_modules/#lmdb/lmdb-linux-x64/
Skipping Git submodules setup
Executing "step_script" stage of the job script
00:35
Using docker image sha256:548714e444f4d0c77d9a6bd243b10715663c73425b28ca648a224f5e31510882 for node:latest with digest node#sha256:d5222e1ebd7dd7e9683f47a8861a4711cb4407a4830cbe04a582ca4986245700 ...
$ echo "Compiling the code..."
Compiling the code...
$ npm install
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: react-server-dom-webpack#0.0.0-experimental-c8b778b7f-20220825
npm WARN Found: react#18.2.0
npm WARN node_modules/react
npm WARN react#"^18.2.0" from the root project
npm WARN 7 more (#gatsbyjs/reach-router, gatsby, gatsby-link, ...)
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer react#"0.0.0-experimental-c8b778b7f-20220825" from react-server-dom-webpack#0.0.0-experimental-c8b778b7f-20220825
npm WARN node_modules/react-server-dom-webpack
npm WARN react-server-dom-webpack#"0.0.0-experimental-c8b778b7f-20220825" from gatsby#5.2.0
npm WARN node_modules/gatsby
npm WARN
npm WARN Conflicting peer dependency: react#0.0.0-experimental-c8b778b7f-20220825
npm WARN node_modules/react
npm WARN peer react#"0.0.0-experimental-c8b778b7f-20220825" from react-server-dom-webpack#0.0.0-experimental-c8b778b7f-20220825
npm WARN node_modules/react-server-dom-webpack
npm WARN react-server-dom-webpack#"0.0.0-experimental-c8b778b7f-20220825" from gatsby#5.2.0
npm WARN node_modules/gatsby
added 3 packages, changed 1 package, and audited 1363 packages in 9s
212 packages are looking for funding
run `npm fund` for details
14 vulnerabilities (1 low, 12 moderate, 1 high)
To address issues that do not require attention, run:
npm audit fix
To address all issues (including breaking changes), run:
npm audit fix --force
Run `npm audit` for details.
$ npm install -g gatsby-cli
added 328 packages in 18s
53 packages are looking for funding
run `npm fund` for details
$ gatsby build --verbose
verbose 0.689606309 set gatsby_log_level: "verbose"
verbose 0.691542062 set gatsby_executing_command: "build"
verbose 0.692319145 loading local command from: /builds/Toddrickson/my-static-website/node_modules/gatsby/dist/commands/build.js
verbose 3.321975841 running command: build
verbose 3.323810293 Running build in "production" environment
error There was an unhandled error during compilation for /builds/Toddrickson/my-static-website. Please run the command with the --verbose flag again.
std::bad_alloc
Error: std::bad_alloc
not finished compile gatsby files - 0.140s
ERROR: Job failed: exit code 1`
`
**tried making updates .....**
`TODDs-iMac:~ Toddrickson$ docker --version
Docker version 20.10.21, build baeda1f
TODDs-iMac:~ Toddrickson$ gitlab-runner --version
Version: 15.7.1
Git revision: 6d480948
Git branch: 15-7-stable
GO version: go1.18.9
Built: 2022-12-19T12:29:15+0000
OS/Arch: darwin/amd64
TODDs-iMac:~ Toddrickson$ npm --version
8.19.2
TODDs-iMac:~ Toddrickson$ gatsby --version
Gatsby CLI version: 5.1.0
TODDs-iMac:~ Toddrickson$
`
Still getting this error.
I would suggest this question be marked as a duplicate of Why clean install of Gatsby throws warnings for react-server-dom-webpack. It was answered by a man who raised an official issue on Gatsby GitHub page related to those warnings and received an official response by a member of Gatsby team that this issue has everything to do with an experimental build of react-server-dom-webpack which Gatsby is using for Partial Hydration. The official comment on the matter can be found here

Getting error while running the Jenkins job for Cypress automation test : The cypress npm package is installed, but the Cypress binary is missing

I am getting the below error while running the jenkins job which i have integrated for cypress test cases.
Running as SYSTEM
Building in workspace C:\Users\Gaurav\CypressAutomation
[CypressAutomation] $ cmd /c call C:\Windows\TEMP\jenkins16040665516745242535.bat
C:\Users\Gaurav\CypressAutomation>npm install && npm run "test"
up to date, audited 651 packages in 5s
65 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
> cypressautomation#1.0.0 test
> node_modules\.bin\cypress run
The cypress npm package is installed, but the Cypress binary is missing.
We expected the binary to be installed here: C:\Windows\system32\config\systemprofile\AppData\Local\Cypress\Cache\11.2.0\Cypress\Cypress.exe
Reasons it may be missing:
- You're caching 'node_modules' but are not caching this path: C:\Windows\system32\config\systemprofile\AppData\Local\Cypress\Cache
- You ran 'npm install' at an earlier build step but did not persist: C:\Windows\system32\config\systemprofile\AppData\Local\Cypress\Cache
Properly caching the binary will fix this error and avoid downloading and unzipping Cypress.
Alternatively, you can run 'cypress install' to download the binary again.
https://on.cypress.io/not-installed-ci-error
----------
Platform: win32-x64 (10.0.19043)
Cypress Version: 11.2.0
Build step 'Execute Windows batch command' marked build as failure
[htmlpublisher] Archiving HTML reports...
[htmlpublisher] Archiving at BUILD level C:\Users\Gaurav\CypressAutomation\cypress\reports\html to C:\Users\Gaurav\.jenkins\jobs\CypressAutomation\builds\18\htmlreports\Cypress_20Report
ERROR: Specified HTML directory 'C:\Users\Gaurav\CypressAutomation\cypress\reports\html' does not exist.
Finished: FAILURE
Please find the configuartion
for CI you can use the npm ci command which designed for this purpose.
Here the doc: https://docs.npmjs.com/cli/v9/commands/npm-ci

Codebuild is unable to find build directory

I am running my buildspec.yml where after npm run build command it should create the build directory in the root path, however, codebuild is unable to find the build directory.I have tried all possible ways from the resources, still I am unable to resolve "no matching base directory path found for build"
PS: I am using codecommit as the source, codebuild & codepipeline to run the deployment steps and S3 bucket to deploy the build directory.
My buildspec.yml
version: 0.2
phases:
install:
runtime-versions:
nodejs: 10
pre_build:
commands:
- echo Installing dependencies...
- npm cache clean --force
- npm install
- npm --version
build:
commands:
- aws s3 rm s3://bucketname --recursive
post_build:
commands:
- pwd
- cd src
- npm run build
- ls -la
- aws s3 sync build s3://bucketname
artifacts:
files:
- "**/*"
I had to remove cd src from the post_build stage because my build and then it worked with pipeline, without any error.

Azure DevOps - how to build bundles using webpack during deployment

I have been trying to deploy an web app to local IIS by using Azure DevOps Repos and Pipelines.
I would like to build bundles using webpack on Azure DevOps service rather than uploading already bundled javascript, style files to Azure Repos.
FYI,
App uses ASP.NET Core 2.2, webpack 4.30, webpack-cli 3.3.2, and configs with webpack.config.js (contains bunch of settings to create bundles in 'dist' folder)
and javascript, style files are in wwwroot folder.
So far it works fine if I upload to Repos with already bundled files in "dist" folder.
But I would like to upload only source files and let Azure DevOps Repos or Pipelines to build bundles and create artifacts with it.
So far, I have been trying to use azure-pipelines.yml
- task: NodeTool#0
inputs:
versionSpec: '12.x'
- task: CmdLine#2
inputs:
script: |
cd (folder)
cd (other folder-where package.json is located)
npm install -g webpack webpack-cli --save-dev
npm install
npx webpack --config webpack.config.js
or
- task: CmdLine#2
inputs:
script: |
cd (folder)
cd (folder)
npm install webpack webpack-cli --save-dev
webpack
npm run build (which is just 'webpack')
both don't work. It seems npm install works but it doesn't even run the webpack part.
because I use 'webpack-messages' on webpack.config.js file so I am expecting some messages such as "Building something bundle..." but it does not show any message regarding webpack process.
Below messages are from a build log.
Starting: Webpack install and build
==============================================================================
Task : Command line
Description : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
Version : 2.163.0
Author : Microsoft Corporation
Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
==============================================================================
Generating script.
========================== Starting Command Output ===========================
"C:\windows\system32\cmd.exe" /D /E:ON /V:OFF /S /C "CALL "d:\a\_temp\fc9874eb-1e72-4a4f-82af-2d3b62451eb7.cmd""
npm WARN rollback Rolling back readable-stream#2.3.6 failed (this is probably harmless): EPERM: operation not permitted, scandir 'D:\a\1\s\something\something\node_modules\fsevents\node_modules'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.11 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.11: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
+ webpack-cli#3.3.11
+ webpack#4.41.6
added 388 packages from 217 contributors and audited 5566 packages in 31.587s
3 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
I tried also on release pipeline.
I added tasks such as 'npm install', 'npm custom', or 'command line' or 'webpack' extension from Dealogic, but none of them works since I can't specify where package.json is located on the Azure DevOps Cloud machine.
Please let me know if it is possible, and if so, how to do it.
According to Microsoft's documentation, it seems that a "webpack" command in the script section of your YAML pipeline should do the trick:
- script: webpack
The condition is: "To have this work, make sure that webpack is configured as a development dependency in your package.json project file. This will run webpack with the default configuration unless you have a webpack.config.js file in the root folder of your project."
They also mention you need to do this after your compilation and tests. There's a suggestion that you can move this logic out of the pipeline and into your code by using script objects in package.json:
- script: npm run build
Source: Microsoft docs
EDIT: The way I've done it is the with the 2nd recommendation. I have this in my MVC ASP.NET project file:
<Target Name="AfterBuild">
<Exec Condition="$(Configuration) == 'Debug'" Command="npm run build-dev" />
<Exec Condition="$(Configuration) == 'Release'" Command="npm run build-prod"/>
</Target>
and build-prod for example is just a script in the webpack.config.js:
"build-prod": "SET NODE_ENV=production && webpack -p --color"
build-dev has the -d argument instead but that's all...

CI Runner - use G++ 4.8 for npm install step

I want to have CI Runner use G++ 4.8 for npm install step. I am messing around witht he .gitlab-ci.yml - here is my current version:
before_script:
- . /etc/profile.d/_environment.sh
- . /etc/profile.d/runner.sh
- nvm use v5.3.0
build:
script:
- scl enable devtoolset-2 bash
- g++ --version
- npm install
- gulp build
tags:
- shell
style-analysis:
script:
- gulp style
tags:
- shell
Unforutnately my build is failing. The step "scl enable devtoolset-2 bash" should sweitch to G++ 4.8 and it does when I runner it on the console directly. The next line "g++ --version" is meant to capture the version so I can debug what is happening here. It is not show version 4.8 instead 4.4. Whcih will cause my build to fail. Here is the "head" of the output
gitlab-ci-multi-runner 0.7.2 (998cf5d)
Using Shell executor...
Running on hqdevrunner01...
Fetching changes...
Removing node_modules/
HEAD is now at 082a6fa remove allow failure
From https://hqdevgit01.services.com/operations/-technical-operations-portal
082a6fa..9e36ed9 master -> origin/master
Checking out 9e36ed91 as master...
Previous HEAD position was 082a6fa... remove allow failure
HEAD is now at 9e36ed9... g++4.8 and c++ 11 feaures enabled as part of build
$ . /etc/profile.d/_environment.sh
$ . /etc/profile.d/runner.sh
$ nvm use v5.3.0
Now using node v5.3.0 (npm v3.3.12)
$ scl enable devtoolset-2 bash
$ npm install
npm WARN deprecated lodash#1.0.2: lodash#<2.0.0 is no longer maintained. Upgrade to lodash#^3.0.0
npm WARN install Couldn't install optional dependency: Unsupported
npm WARN engine xmlbuilder#2.4.4: wanted: {"node":"0.8.x || 0.10.x || 0.11.x"} (current: {"node":"5.3.0","npm":"3.3.12"})
npm WARN deprecated lodash-node#2.4.1: This package is no longer maintained. See its readme for upgrade details.
> ursa#0.9.1 install /home/gitlab-runner/builds/6acc3401/0/operations/-technical-operations-portal/node_modules/chef-api/node_modules/ursa
> node-gyp rebuild
make: Entering directory `/home/gitlab-runner/builds/6acc3401/0/operations/-technical-operations-portal/node_modules/chef-api/node_modules/ursa/build'
CXX(target) Release/obj.target/ursaNative/src/ursaNative.o
In file included from ../src/ursaNative.h:10,
from ../src/ursaNative.cc:3:
../node_modules/nan/nan.h:41:3: error: #error This version of node/NAN/v8 requires a C++11 compiler
In file included from /home/gitlab-runner/.node-gyp/5.3.0/include/node/node.h:42,
from ../src/ursaNative.h:9,
from ../src/ursaNative.cc:3:
It looks as though the value from one step is not carried forward to the next step. For instance - as if they happen in their own shells.
GITLAB is actively working to move this project forward. At this point, the work in one step is not carried forward to other steps. I beleive the theory is that each step can be carried our in parallel on different CI Runners.
My solution: MEGA STEP
build:
script:
- scl enable devtoolset-2 bash
- g++ --version
- npm install
- gulp build
- gulp style
tags:
- shell
Its a work arond for now.

Resources