Why does my Angular project pipeline keep failing? - node.js

I have a angular project that I'm trying to tag and push to dev server using git and gitlab.
After my 4th unsuccessful try, I'm now at a loss to what I'm doing wrong.
This is my job log:
[0KRunning with gitlab-runner 12.9.0 (4c96e5ad)
[0;m[0K on dev-runner yMELGGtz
[0;msection_start:1608540813:prepare_executor
[0K[0K[36;1mPreparing the "shell" executor[0;m
[0;m[0KUsing Shell executor...
[0;msection_end:1608540813:prepare_executor
[0Ksection_start:1608540813:prepare_script
[0K[0K[36;1mPreparing environment[0;m
[0;mRunning on WIN-AVAH5M2LJ5E...
section_end:1608540814:prepare_script
[0Ksection_start:1608540814:get_sources
[0K[0K[36;1mGetting source from Git repository[0;m
[0;m[32;1mFetching changes with git depth set to 50...[0;m
Reinitialized existing Git repository in C:/runner/builds/yMELGGtz/0/gitlab_username/project_name-auth-front/.git/
From https://gitlab.com/gitlab_username/project_name-auth-front
* [new ref] refs/pipelines/232677922 -> refs/pipelines/232677922
* [new tag] v20201221.3 -> v20201221.3
[32;1mChecking out 2e8cffbc as v20201221.3...[0;m
Removing node_modules/
git-lfs/2.10.0 (GitHub; windows amd64; go 1.12.7; git a526ba6b)
[32;1mSkipping Git submodules setup[0;m
section_end:1608540861:get_sources
[0Ksection_start:1608540861:restore_cache
[0K[0K[36;1mRestoring cache[0;m
[0;msection_end:1608540862:restore_cache
[0Ksection_start:1608540862:download_artifacts
[0K[0K[36;1mDownloading artifacts[0;m
[0;msection_end:1608540863:download_artifacts
[0Ksection_start:1608540863:build_script
[0K[0K[36;1mRunning before_script and script[0;m
[0;m[32;1m$ npm i[0;m
npm WARN deprecated ini#1.3.5: Please update to ini >=1.3.6 to avoid a prototype pollution issue
> core-js#3.6.5 postinstall C:\runner\builds\yMELGGtz\0\gitlab_username\project_name-auth-front\node_modules\core-js
> node -e "try{require('./postinstall')}catch(e){}"
> #angular/cli#11.0.4 postinstall C:\runner\builds\yMELGGtz\0\gitlab_username\project_name-auth-front\node_modules\#angular\cli
> node ./bin/postinstall/script.js
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.13 (node_modules\webpack-dev-server\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.13 (node_modules\watchpack-chokidar2\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#2.1.3 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
added 1650 packages from 1206 contributors and audited 1654 packages in 113.077s
79 packages are looking for funding
run `npm fund` for details
found 3 low severity vulnerabilities
run `npm audit fix` to fix them, or `npm audit` for details
[32;1m$ npm run build-dev[0;m
> project_name-auth#0.0.0 build-dev C:\runner\builds\yMELGGtz\0\gitlab_username\project_name-auth-front
> ng build --hmr --base-href /auth/ --deploy-url /auth/
Unknown option: '--hmr'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! project_name-auth#0.0.0 build-dev: `ng build --hmr --base-href /auth/ --deploy-url /auth/`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the project_name-auth#0.0.0 build-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:\Windows\system32\config\systemprofile\AppData\Roaming\npm-cache\_logs\2020-12-21T08_56_23_982Z-debug.log
section_end:1608540984:build_script
[0Ksection_start:1608540984:upload_artifacts_on_failure
[0K[0K[36;1mUploading artifacts for failed job[0;m
[0;msection_end:1608540985:upload_artifacts_on_failure
[0K[31;1mERROR: Job failed: exit status 1
[0;m
Please note that my OS is Ubuntu 20.04 and I have replaced gitlab username and project name in the log with gitlab_username and project_name. (because it's not my project or my repository)

Expanding what #MikeOne wrote in the comment and as stated in webpack Hot Module Replacement documentation,
HMR is not intended for use in production, meaning it should only be
used in development.
Previously, in my package.json I had:
"scripts": {
"build": "ng build --prod --hmr --base-href /auth/ --deploy-url /auth/",
"build-dev": "ng build --hmr --base-href /auth/ --deploy-url /auth/"
},
So, I just changed it to:
"scripts": {
"build": "ng build --prod --base-href /auth/ --deploy-url /auth/",
"build-dev": "ng build --base-href /auth/ --deploy-url /auth/"
},
And it worked!

Related

Can't run npm install on Ubuntu 20.4 server

I have a node.js application that I want to run on an Ubuntu 20.4 server, when I try to run the command npm install, I see the following error, I do not have root access on the server, where can this problem be? I have version 6.14.3 of npm and version 14.15.3, how can i deal with this problem?
```
npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion#1, but package-lock.json was generated for lockfileVersion#2. I'll try to do my best with it!
> core-js#2.6.12 postinstall /var/www/site/public_html/node_modules/#nuxt/babel-preset-app/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"
Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!
The project needs your help! Please consider supporting of core-js on Open Collective or Patreon:
> https://opencollective.com/core-js
> https://www.patreon.com/zloirock
Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)
> core-js#3.10.2 postinstall /var/www/site/public_html/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"
> bootstrap-vue#2.21.2 postinstall /var/www/site/public_html/node_modules/bootstrap-vue
> opencollective || exit 0
sh: 1: opencollective: Permission denied
> nuxt#2.15.4 postinstall /var/www/site/public_html/node_modules/nuxt
> opencollective || exit 0
sh: 1: opencollective: Permission denied
> swiper#5.4.5 postinstall /var/www/site/public_html/node_modules/swiper
> echo "Love Swiper? Support Vladimir's work by donating or pledging on patreon:
> https://patreon.com/vladimirkharlampidi
"
Love Swiper? Support Vladimir's work by donating or pledging on patreon:
> https://patreon.com/vladimirkharlampidi
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.13 (node_modules/watchpack-chokidar2/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#2.3.2 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
added 1334 packages from 697 contributors and audited 1338 packages in 17.59s
102 packages are looking for funding
run `npm fund` for details
found 58 vulnerabilities (39 moderate, 18 high, 1 critical)
run `npm audit fix` to fix them, or `npm audit` for details
```
This might have the issue with permission
Try this
sudo npm cache clean
sudo npm install

Gatsby default starter

This error came when I created gatsby-default-starter site. How to solve it. What is the problem with it?
Error message:
‼ pngquant pre-build test failed i compiling from source × Error: pngquant failed to build, make sure that libpng-dev is installed at D:\gatsby-project\my-gatsby-project\node_modules\bin-build\node_modules\execa\index.js:231:11 at runMicrotasks () at processTicksAndRejections (internal/process/task_queues.js:93:5) at async Promise.all (index 0) npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.13 (node_modules\webpack-dev-server\node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}) npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#2.3.2 (node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! pngquant-bin#6.0.0 postinstall: node lib/install.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the pngquant-bin#6.0.0 postinstall 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:
ERROR
Command failed with exit code 1: npm install
Error: Command failed with exit code 1: npm install
error.js:56 makeError [npm]/[gatsby-cli]/[execa]/lib/error.js:56:11
index.js:114 handlePromise [npm]/[gatsby-cli]/[execa]/index.js:114:26
task_queues.js:93 processTicksAndRejections internal/process/task_queues.js:93:5
init-starter.js:135 install [npm]/[gatsby-cli]/lib/init-starter.js:135:7
init-starter.js:202 clone [npm]/[gatsby-cli]/lib/init-starter.js:202:3
init-starter.js:343 initStarter [npm]/[gatsby-cli]/lib/init-starter.js:343:5
create-cli.js:494 [npm]/[gatsby-cli]/lib/create-cli.js:494:9
It seems that you are using Windows as OS. This issue is usually related to some additional dependencies that you may need. Try the following:
Delete your project (to avoid potentially corrupted dependencies).
Install the windows-build-tools by:
npm install --global windows-build-tools --vs2015
Run your starter command and develop it. For example:
npm install -g gatsby-cli
gatsby new gatsby-site
cd gatsby-site
gatsby develop
If the issue persists try installing manually the missing dependencies by:
npm install imagemin-pngquant#5.0.1 --save
npm install pngquant-bin#3.1.1 --save
For further details check Gatsby on Windows docs.

How to resolve an error with npm run serve

I am new to Vue. I had successfully created projects for a while now, with no issues. However, today I created a new project, and when I tried “npm run serve” I got back three errors out of nowhere.
Even old projects that were serving fine, I cant serve them again
I am using windows 7, so the node version is 13.14.0
This is the error I get:
ERROR Failed to compile with 3 errors
10:46:02 PM
ERROR Failed to compile with 3 errors
10:46:02 PM
These dependencies were not found:
* C:\Users\hp\Documents\vue full learn\dojo-blog-
composition\node_modules\webpack-dev-server\client\index.js?
http://192.168.43.35:8081&sockPath=/sockjs-node in multi
(webpack)-dev-server/client?
http://192.168.43.35:8081&sockPath=/sockjs-node
(webpack)/hot/dev-server.js ./src/main.js
* C:\Users\hp\Documents\vue full learn\dojo-blog-
composition\node_modules\webpack\hot\dev-server.js in multi
(webpack)-dev-server/client?
http://192.168.43.35:8081&sockPath=/sockjs-node
(webpack)/hot/dev-server.js ./src/main.js
To install them, you can run: npm install --save
C:\Users\hp\Documents\vue full learn\dojo-blog-
composition\node_modules\webpack-dev-
server\client\index.js?
http://192.168.43.35:8081&sockPath=/sockjs-node
C:\Users\hp\Documents\vue full learn\dojo-blog-
composition\node_modules\webpack\hot\dev-server.js
This relative module was not found:
* ./src/main.js in multi (webpack)-dev-server/client?
http://192.168.43.35:8081&sockPath=/sockjs-node
(webpack)/hot/dev-server.js ./src/main.js
I checked and the webpack-dev-server is in the node-bundles folder.
when I tried installing as directed above, I got more errors:
npm ERR! code ENOLOCAL
npm ERR! Could not install from "..\..\..\Documents\vue" as it
does not contain a package.json file.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\hp\AppData\Roaming\npm-
cache\_logs\2021-01-02T22_03_20_183Z-debug.log
'sockPath' is not recognized as an internal or external command,
operable program or batch file.
This is the package.json
{
"name": "project-planner",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build"
},
"dependencies": {
"core-js": "^3.6.5",
"vue": "^3.0.0",
"vue-router": "^4.0.0-0"
},
"devDependencies": {
"#vue/cli-plugin-babel": "~4.5.0",
"#vue/cli-plugin-router": "~4.5.0",
"#vue/cli-service": "~4.5.0",
"#vue/compiler-sfc": "^3.0.0",
"webpack-dev-server": "^3.11.2"
}
}
I get this with I use npm install
npm WARN deprecated #hapi/joi#15.1.1: Switch to 'npm install joi'
npm WARN deprecated request#2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
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 #hapi/bourne#1.3.2: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated #hapi/hoek#8.5.1: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated #hapi/address#2.1.4: Moved to 'npm install #sideway/address'
npm WARN deprecated #hapi/topo#3.1.6: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated har-validator#5.1.5: this library is no longer supported
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 WARN deprecated urix#0.1.0: Please see https://github.com/lydell/urix#deprecated
> core-js#3.8.3 postinstall C:\Users\hp\My Documents\webdev\projects\learnVue\project-planner\node_modules\core-js
> node -e "try{require('./postinstall')}catch(e){}"
Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!
The project needs your help! Please consider supporting of core-js on Open Collective or Patreon:
> https://opencollective.com/core-js
> https://www.patreon.com/zloirock
Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)
> ejs#2.7.4 postinstall C:\Users\hp\My Documents\webdev\projects\learnVue\project-planner\node_modules\ejs
> node ./postinstall.js
Thank you for installing EJS: built with the Jake JavaScript build tool (https://jakejs.com/)
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#~2.3.1 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#2.3.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"ia32"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#^1.2.7 (node_modules\watchpack-chokidar2\node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"ia32"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#^1.2.7 (node_modules\webpack-dev-server\node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"ia32"})
added 1214 packages from 934 contributors and audited 1217 packages in 527.888s
61 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities

Install nest.js on Centos 7

I am installing nest.js on CentOS 7. I get this error:
file:///usr/lib/node_modules/#nestjs/cli/node_modules/#nuxtjs/opencollective/src/index.js:7
;(async () => {
^
SyntaxError: Unexpected token (
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#^1.2.2 (node_modules/#nestjs/cli/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! Linux 3.10.0-693.21.1.el7.x86_64
npm ERR! argv "/usr/bin/node" "/bin/npm" "i" "-g" "#nestjs/cli"
npm ERR! node v6.14.3
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! #nestjs/cli#5.5.0 postinstall: `opencollective`
npm ERR! Exit status 1
Any idea?
The answer lies right in the error message:
npm ERR! node v6.14.3
Not sure which version of nest.js you are trying to install, but the current version has this requirement:
"engines": {
"node": ">= 8.9.0"
},
See official nest.js packages.json.
This works on my centos 7. The command that I used are
[root#yellowdog ~]# npm install -g #nestjs/cli
/usr/bin/nest -> /usr/lib/node_modules/#nestjs/cli/bin/nest.js
> #nestjs/cli#5.5.0 postinstall /usr/lib/node_modules/#nestjs/cli
> opencollective
Thanks for installing nest 🙏
Please consider donating to our open collective
to help us maintain this package.
Number of contributors: 54
Number of backers: 97
Annual budget: US$ 37,495
Current balance: US$ 246
👉 Become a partner: https://opencollective.com/nest/donate
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.4 (node_modules/#nestjs/cli/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
+ #nestjs/cli#5.5.0
added 215 packages from 173 contributors in 20.529s
[root#yellowdog ~]# node -v
v8.11.4
[root#yellowdog ~]# npm -v
6.4.1
[root#yellowdog ~]# nest --version
5.5.0

npm install lite-server --save-dev error

I'm trying to use node for the first time in a VS project in windows. I installed node.js, below is the info:
node -v
v8.9.3
npm -v
5.5.1
Completed setup in the project using npm init, that seemed to work fine.
npm install lite-server --save-dev produced the following error:
$ npm install lite-server --save-dev
npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for fsevents#1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm ERR! notsup Valid OS: darwin
npm ERR! notsup Valid Arch: any
npm ERR! notsup Actual OS: win32
npm ERR! notsup Actual Arch: x64
I don't understand the errors. Help. Thanks!
The error comes from fsevents#1.1.3, which is a dependency package of lite-server.
fsevents#1.1.3 only works in macOS. See its npm info page.
Native access to OS X FSEvents in Node.js
The FSEvents API in OS X allows applications to register for
notifications of changes to a given directory tree. It is a very fast
and lightweight alternative to kqueue.
Similar issues also apply to other npm packages with such dependency.
I am using npm#5.6.0, the latest stable release, and tried install on my Windows. The error turns out to a warning and let lite-server installed eventually. Anyway, fsevents is just an optional dependency.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.1.3 (node_modules\lite-server\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
+ lite-server#2.3.0
added 279 packages in 81.466s
I found the fix for Ubuntu 18.04/20.04 after working for whole day. This should work for other Linux distros
Run following command for globally using lite-server
sudo npm install lite-server -g
Your package.json file should contain
"devDependencies": {
"lite-server": "^2.5.4"
}
and scipt should look like
"scripts": {
"start": "npm run lite",
"test": "echo \"Error: no test specified\" && exit 1",
"lite": "lite-server"
},
For development mode run following
sudo npm i lite-server --save-dev
Local server could started using npm command
npm start

Resources