Error "error hashing files" in Docker on npm run build - javascript

I'm using basic Dockerfile which looks like this one:
WORKDIR /
COPY . /
RUN npm install
RUN npm run build
My project is monorepo (made with turborepo) consisting API and Frontend packages. When I start the image using docker compose it fails on step npm run build with following error:
#9 0.943 ERROR error hashing files. make sure that git has been initialized git hash-object exited with status: exec: "git": executable file not found in $PATH
------
failed to solve: rpc error: code = Unknown desc = executor failed running [/bin/sh -c npm run build]: exit code: 1
Building it locally (Windows) works perfect without any errors.
Any ideas?

Related

How to resolve 'Unexpected end of JSON input' using typed-azure-functions?

I am using azure functions core tools from a cloned repository with a shopify microservice. The project setup has these steps:
npm install
npm run build
npm run typed-az-func -- push
npm run typed-az-func -- push --execute
npm run typed-az-func -- pull
I was logged in on azure using the azure-cli. In the last command (npm run typed-az-func -- pull), I've encountered some errors:
Command errors
I'm running Ubuntu 20.04.3 LTS
and installed Azure Function Core Tools from this: https://learn.microsoft.com/en-us/azure/azure-functions/functions-run-local?tabs=v3%2Clinux%2Ccsharp%2Cportal%2Cbash%2Ckeda
There's a high chance that your npm cache been damaged.
Try npm cache clean --force command before npm run command and this should resolve the issue.

problem while deploying react application to github

I created a todolist that is working properly in localhost.
Iam trying to deploy it on github, when I run '$ npm run deploy' in command propmt it showing error p
Added homepage, predeploy, deploy properties to package.json
installed gh-pages --save-dev
Please help I am a beginner
This is the command prompt error.
C:\Users\Syed\Desktop\project\todolist>npm run deploy
> todolist#0.1.0 predeploy C:\Users\Syed\Desktop\project\todolist
> npm run build
> todolist#0.1.0 build C:\Users\Syed\Desktop\project\todolist
> react-scripts build
Creating an optimized production build...
Compiled with warnings.
./src/App.js
Line 2:8: 'logo' is defined but never used no-unused-vars
Line 52:20: Expected to return a value in arrow function array-callback-return
Search for the keywords to learn more about each warning.
To ignore, add // eslint-disable-next-line to the line before.
File sizes after gzip:
55.54 KB build\static\js\2.0512a152.chunk.js
1.19 KB build\static\js\main.1e3fd05a.chunk.js
785 B build\static\js\runtime-main.ce724f51.js
657 B build\static\css\main.362672fb.chunk.css
The project was built assuming it is hosted at /To-Do-List/.
You can control this with the homepage field in your package.json.
The build folder is ready to be deployed.
Find out more about deployment here:
bit.ly/CRA-deploy
> todolist#0.1.0 deploy C:\Users\Syed\Desktop\project\todolist
> gh-pages -d build
fatal: A branch named 'gh-pages' already exists.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! todolist#0.1.0 deploy: `gh-pages -d build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the todolist#0.1.0 deploy 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\Syed\AppData\Roaming\npm-cache\_logs\2020-07-02T01_49_57_997Z-debug.log
Please check this quickstart guide
You will need to set up the GitHub pages homepage link on your GitHub repository settings page first.
Then check the source as well.
Then save. That should work.
To solve the issue with
fatal: A branch named 'gh-pages' already exists.
remove the 'gh-pages/' folder at node_modeules/.cache/
This worked for me
I am not professional in react and these tools.
But error log states that you already have a branch named "gh-pages" check your github repository and delete it.
You would find this if you've searched a little bit.
Delete node_modules/gh-pages/.cache and try again.
Linux / macOS / Git bash: rm -rf node_modules/gh-pages/.cache

How to configure Travis CI to build Node.js without tests?

I have a Node.js project as a GitHub repo. There are currently no tests written for the project. My goal is to simply build the project successfully with Travis-CI, without any tests.
I'm currently using the following basic Travis config, .travis.yml:
language: node_js
node_js:
- "node"
install:
- npm install
The above will fail for me, with the following output:
[0Ktravis_fold:end:nvm.install
[0K$ node --version
v9.11.1
$ npm --version
5.6.0
$ nvm --version
0.33.8
travis_fold:start:install
[0Ktravis_time:start:154792e9
[0K$ npm install
[37;40mnpm[0m [0m[30;43mWARN[0m[35m[0m repoName#1.0.0 No repository field.
[0m
up to date in 0.599s
[0Ktravis_fold:end:install
[0Ktravis_time:start:3e0b4d3c
[0K$ npm test
> repoName#1.0.0 test /home/travis/build/githubHandle/repoName.js
> echo "Error: no test specified" && exit 1
Error: no test specified
[37;40mnpm[0m [0m[31;40mERR![0m[35m[0m Test failed. See above for more details.
[0m
I don't understand why npm test is being run. It appears to be failing, as no tests have been written. How could I build/install on Travis without checking for tests?
npm test is the default build script for nodejs projects.
If you haven't unit tests or build task, you can skip this step. To do that, add the following line in your travis config file:
script: 'true'

NodeJS (Firebase): Cannot import custom class

I am working on a Firebase server-side code for sending push notifications. To make the code clean, I decided to move some functions to another class which I created and called notificationFunctions.js.
When I do const notificationFunctions = require('notificationFunctions'); at the top of my index.js and call the function from within my sendNotification function, I get an error when deploying my project to the cloud:
⚠ functions[sendNotifications]: Deployment error.
Build failed: exit status 1
npm ERR! Linux 4.4.0-108-generic
npm ERR! argv "/nodejs/bin/node" "/nodejs/bin/npm" "--global-style" "--production" "--fetch-retries=5" "--fetch-retry-factor=2" "--fetch-retry-mintimeout=1000" "install" "/workspace"
npm ERR! node v6.11.5
npm ERR! npm v3.10.10
npm ERR! code E404
npm ERR! 404 Registry returned 404 for GET on https://registry.npmjs.org/notificationFunctions
npm ERR! 404
npm ERR! 404 'notificationFunctions' is not in the npm registry.
npm ERR! 404 Your package name is not valid, because
npm ERR! 404 1. name can no longer contain capital letters
npm ERR! 404 It was specified as a dependency of 'functions'
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
npm ERR! Please include the following file with any support request:
npm ERR! /workspace/npm-debug.log
Functions deploy had errors. To continue deploying other features (such as database), run:
firebase deploy --except functions
I have also added "notificationFunctions": "1.0.0" in my package.json and moved the custom function to node_modules folder.
What is the right way of adding a custom class to Firebase NodeJS?
Edit:
When I follow Doug Stevenson's advise and I remove the custom class from my package.json, and move the class to the same directory as index.js, I still keep getting an error:
i deploying functions
i functions: ensuring necessary APIs are enabled...
✔ functions: all necessary APIs are enabled
i functions: preparing functions directory for uploading...
Error: Error parsing triggers: Cannot find module 'notificationFunctions'
Try running "npm install" in your functions directory before deploying.
Edit 2
Ok. I figured I have to change the way I import my class to require('./notificationFunctions') and this removes all errors when deploying the project.
Once I run the code on the cloud however, I get this error: FIREBASE WARNING: Exception was thrown by user callback. TypeError: notificationFunctions.getNotificationPayload is not a function
The way I call the function from my code is: const payload = notificationFunctions.getNotificationPayload(userLanguage, senderName, groupName, messageContent, messageType);
If you add code to your project in the functions folder, you don't need to make any changes to your package.json dependencies. npm dependencies are only required for modules that are published to the NPM registry.
What your build is doing now is looking for a node module called "notificationFunctions" on NPM, and that obviously doesn't exist there. You should just put your module code along with all the other code under functions and require() it directly from there.
Also, bear in mind that node_modules is not deployed with your code. Cloud Functions will fetch all the npm dependencies on the server side and make them available to your code.

NodeJS command "npm install express --save" raising exception

I have NodeJS installed and am trying to do this tutorial for making a NodeJS chat app: http://socket.io/get-started/chat/
I created the package.json file in it's own dedicated folder, and executed in the windows command prompt this npm command from the tutorial I linked.
npm install --save express#4.10.2
The error I receive is as follows:
Error: ENOENT, stat 'C:\Users\david\AppData\Roaming\npm'
So I wemt to the ExpressJS page, tried the command they list on their site, which is.
npm install express --save
And I receive the same error. Anyone know how to fix this, please?

Categories