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'
Related
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?
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
I'm trying to deploy my project to Firebase Hosting using the following action:
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
deploy_to_firebase_hosting:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout#master
- name: Install Dependencies
run: npm install
- name: Build for production
run: npm run build-prod
- name: Deploy to Firebase
uses: w9jds/firebase-action#master
with:
args: deploy --only hosting
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
The actions gets failed on Build For Production step. My build-prod script does webpack -p --mode production.
This is the error message for this failure:
> project-name#1.0.0 build-prod /home/runner/work/project-name/project-name
> webpack -p --mode production
/home/runner/work/project-name/project-name/node_modules/webpack-cli/bin/cli.js:93
throw err;
^
TypeError: Cannot convert undefined or null to object
at Function.keys (<anonymous>)
...
I've been researching about this error and I found out that people solve it by deleting node_modules before running the build. So I ran another action, without the npm install part.
It fails again on Build for production, but with a different, much reasonable error:
> webpack -p --mode production
webpack not installed
Install webpack to start bundling:
$ npm install --save-dev webpack
npm ERR! code ELIFECYCLE
npm ERR! errno 1
What's the correct way to build a production bundle in Github Actions?
Thanks!
I had the exact same issue when trying to use GitHub actions to build & deploy a production Docker container.
It turned out the issue on my side was as a result of Webpack not having access to any environment variables (which my Webpack config required) at the point of build which caused it to error out with the same error you received above.
To fix this I added the following line to my build command:
--env.NODE_ENV=production
E.g my final build command called by the container was then:
node --max_old_space_size=4096 ./node_modules/webpack/bin/webpack.js --env.NODE_ENV=production --progress --config webpack.prod.js
Hope this helps!
I need to unit-test my rest api written in NodeJS. For this, I need to use supertest npm package. I was following this tutorial article for implementing the unit test functionality.
Now, in this article it is mentioned that mocha is already included in supertest itself, so there's no need to install it separately. So, I only install supertest using - npm install --save-dev supertest.
But, when I add this line in my package.json - "test": "mocha", and run npm test, it gives error saying 'mocha' is not recognized as an internal or external command. I need to run npm install --save-dev mocha to make it run successfully. But why do I need to include mocha separately and if that's how it is supposed to run, why is it not mentioned in this article or on npm homepage of supertest?
I went to Supertest page on npmjs and checked the dependencies. Mocha is listed as a dev dependency. it means Mocha was used while creating supertest, but is not required for supertest to function.
When I work on Node.js project, I install certain packages as dev dependencies. These could be packages for testing (Mocha) or linting (Standard). What it means is when the project is deployed, it will not need these packages to function.
Also, you can use npm list command to see which modules are installed. I just installed supertest and ran npm list. This is structure of supertest :
As you can see Mocha is not listed
Further, ran npm ls mocha and output is:
$ npm ls mocha
nodetest#1.0.0 E:\Nodetest
-- (empty)
and when I ran npm ls supertest, output is:
$ npm ls supertest
nodetest#1.0.0 E:\Nodetest
-- supertest#3.3.0
Why sis the article say mocha is available? may be in an earlier version of supertest it was included as a dependency
I am trying to set up a node.js server on CentOS 7 using grunt and yeoman, but I am getting an error saying that the compass command cannot be found. I read this other posting about a similar error, but the other posting assumes you are using ruby on rails, which I am not. Also, the methods that I am testing come from this tutorial, and things stop working when I get to the point in the tutorial where it says to type grunt serve. I have made several additions to the tutorial to address error messages one by one, but the current error about compass does not seem to have a google-able answer.
What specific steps do I need to take to get grunt to be able to find and use compass?
Here is the current error which is causing grunt serve to fail:
Warning: Running "compass:server" (compass) task
Warning: Command failed: /bin/sh -c compass --version
/bin/sh: compass: command not found
Use --force to continue.
Aborted due to warnings.
Here is the series of commands leading up to this problem:
First, I performed the following installation commands as root:
yum install -y nodejs
yum clean all && yum update
yum install -y gcc-c++ openssl-devel make
npm install -g express
npm install -g express-generator
npm install -g yo
npm install -g generator-angular
npm install -g bower
npm install -g nodemon
npm install -g grunt-cli
npm install generator-karma
npm install -g compass
npm install -g grunt-contrib-compass
Next, I switched to a non-root user account and ran the following commands:
cd /home/user/angular_apps
mkdir /home/user/angular_apps/my_new_project && cd /home/user/angular_apps/my_new_project
mkdir /home/user/angular_apps/my_new_project/client // will house angular and app code
mkdir /home/user/angular_apps/my_new_project/server // will house node and express code, among other things
cd /home/user/angular_apps/my_new_project/client
yo angular // get yeoman to scaffold out the front end
// yeoman asked many questions. I said no to replacing grunt with anything else and I said yes to every other include
npm install // this will install all the required packages
bower install // this will hook up bower and thus prevent a downstream error
grunt serve
The grunt serve command results in the following complete error output:
[user#localhost client]$ grunt serve
Running "serve" task
Running "clean:server" (clean) task
>> 0 paths cleaned.
Running "wiredep:app" (wiredep) task
Running "wiredep:test" (wiredep) task
Running "wiredep:sass" (wiredep) task
Running "concurrent:server" (concurrent) task
Warning: Running "compass:server" (compass) task
Warning: Command failed: /bin/sh -c compass --version
/bin/sh: compass: command not found
Use --force to continue.
Aborted due to warnings.
Execution Time (2016-02-15 23:22:25 UTC)
loading tasks 254ms ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 76%
loading grunt-contrib-compass 28ms ▇▇▇ 8%
compass:server 50ms ▇▇▇▇▇ 15%
Total 333ms Use --force to continue.
Aborted due to warnings.
Execution Time (2016-02-15 23:22:24 UTC)
loading tasks 307ms ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 20%
wiredep:app 254ms ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 17%
wiredep:sass 37ms ▇▇▇ 2%
loading grunt-concurrent 23ms ▇▇ 2%
concurrent:server 865ms ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 57%
Total 1.5s
[user#localhost client]$
Note that the same error message is returned when I try running grunt serve as root instead. So what specific steps need to be taken to resolve this error?
I thought compass was a ruby thing.
try gem install compass
For yum based systems
yum -y install gcc ruby-devel rubygems compass might also work.