I am trying to build my project through travis-ci, but unknown error is happening when travis tries to test the project through mocha. i know the issue is not with mysql since the connection is there and scripts are working.
I am testing using
- ts-node/register
- Mocha
- Chai
- Chai-http
- mySQL (using pool)
The test is working fine locally, but on travis it is failing. i am thinking that it might be something with ts-node/register, in travis.
1 - i have tried remove the test completely and the build was fixed. but when i try to test it fails miserably.
package.json
{
"name": "xxxxxxxxx",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "ENV='PRODUCTION' node dist/app.js --verbose",
"debug": "node --inspect dist/app.js",
"dev": "ENV='DEVELOPMENT' nodemon src/app.ts --verbose",
"build": "tsc -p .",
"test": "ENV='TEST' mocha -r ts-node/register test/{,dbMappers}/**.test.ts --exit; ",
"test:awesome": "ENV='TEST' mocha -r ts-node/register test/{,dbMappers}/**.test.ts --reporter mochawesome --exit; "
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"app-root-path": "^2.2.1",
"bcrypt": "^3.0.6",
"body-parser": "^1.19.0",
"colors": "^1.3.3",
"cors": "^2.8.5",
"dotenv": "^8.0.0",
"express": "^4.17.1",
"jsonwebtoken": "^8.5.1",
"mysql": "^2.17.1",
"uuid": "^3.3.2",
"winston": "^3.2.1"
},
"devDependencies": {
"#types/app-root-path": "^1.2.4",
"#types/bcrypt": "^3.0.0",
"#types/body-parser": "^1.17.0",
"#types/chai": "^4.2.0",
"#types/chai-http": "^4.2.0",
"#types/colors": "^1.2.1",
"#types/cors": "^2.8.5",
"#types/dotenv": "^6.1.1",
"#types/express": "^4.17.0",
"#types/jsonwebtoken": "^8.3.2",
"#types/mocha": "^5.2.7",
"#types/mysql": "^2.15.6",
"#types/node": "^12.6.8",
"#types/uuid": "^3.4.5",
"#types/winston": "^2.4.4",
"chai": "^4.2.0",
"chai-http": "^4.3.0",
"mocha": "^6.2.0",
"mochawesome": "^4.1.0",
"nodemon": "^1.19.1",
"ts-node": "^8.3.0",
"typescript": "^3.5.3"
}
}
.travis.yml
language: node_js
node_js:
- "stable"
directories:
- "node_modules"
services:
- mysql
cache:
- "node_modules"
before_script:
- mysql -u root -e "CREATE USER 'test'#'localhost' IDENTIFIED BY 'xxxx'"
- mysql -u root -e 'CREATE DATABASE backend;'
- mysql -u root -e 'SHOW DATABASES'
- mysql -u root -e "GRANT ALL ON backend.* TO 'test'#'localhost';"
- npm install
env:
- ENV: 'TEST'
The Travis repo
https://travis-ci.com/moh682/hbas-system-api
The error that travis expose is only this.
yyy#1.0.0 test /home/travis/build/xxx/yyy
ENV='TEST' mocha -r ts-node/register test/{,dbMappers}/**.test.ts --exit;
xxx = username | yyy = repo name
Related
... and I know that my json is perfectly valid json.
The problem started when I added some dev dependencies to the package.json, but it seems to be getting tripped up on the first lines. I've verified and cleaned the cache, updated npm, and I've combed through the file and the posts on this problem for a while, but cannot figure out what's going on. I've also tried some suggestions I saw on here, like changing all the " characters to ' characters. Nada.
My package.json is below, as well as the full error message when I run a command:
{
"name": "Outlook Beaty",
"version": "0.2.1",
"description": "A custom experience enhancer for Outlook.",
"repository": {
"type": "git",
"url": "https://github.com/team5-devs/js-outlook-plugin/"
},
"license": "MIT",
"config": {
"app-to-debug": "outlook",
"app-type-to-debug": "desktop",
"dev-server-port": 3000
},
"dependencies": {},
"devDependencies": {
"#babel/core": "^7.11.6",
"#babel/polyfill": "^7.11.5",
"#babel/preset-env": "^7.11.5",
"#types/find-process": "1.2.0",
"#types/office-js": "^1.0.108",
"#types/office-runtime": "^1.0.14",
"babel-loader": "^8.1.0",
"clean-webpack-plugin": "^3.0.0",
"copy-webpack-plugin": "^6.1.1",
"eslint": "^7.19.0",
"eslint-config-office-addins": "^1.0.19",
"find-process": "^1.4.3",
"file-loader": "^4.2.0",
"generator-office": "^1.7.8",
"html-loader": "^0.5.5",
"html-webpack-plugin": "^4.5.0",
"jasmine": "^3.6.4",
"jsdoc": "^3.6.6",
"office-addin-cli": "^1.0.13",
"office-addin-debugging": "^3.0.34",
"office-addin-dev-certs": "^1.5.5",
"office-addin-lint": "^1.0.26",
"office-addin-manifest": "1.5.7",
"office-addin-prettier-config": "^1.0.12",
"source-map-loader": "^0.2.4",
"travis-ci": "^2.2.0",
"ts-loader": "^6.2.2",
"typescript": "^4.0.3",
"webpack": "^4.43.0",
"webpack-cli": "^3.3.12",
"webpack-dev-server": "^3.11.0"
"yo": "^3.1.1"
},
"scripts": {
"build": "webpack -p --mode production --https false",
"build:dev": "webpack --mode development --https false",
"build-dev": "webpack --mode development --https false && echo . && echo . && echo . && echo Please use 'build:dev' instead of 'build-dev'.",
"dev-server": "webpack-dev-server --mode development",
"lint": "office-addin-lint check",
"lint:fix": "office-addin-lint fix",
"prettier": "office-addin-lint prettier",
"start": "office-addin-debugging start manifest.xml",
"start:desktop": "office-addin-debugging start manifest.xml desktop",
"start:web": "office-addin-debugging start manifest.xml web",
"stop": "office-addin-debugging stop manifest.xml",
"test": "jasmine",
"validate": "office-addin-manifest validate manifest.xml",
"watch": "webpack --mode development --watch"
}
}
npm install
npm ERR! JSON.parse "name": "Outlook Beaty",
npm ERR! JSON.parse "versio'
npm ERR! JSON.parse Failed to parse package.json data.
npm ERR! JSON.parse package.json must be actual JSON, not just JavaScript.
Any help would be greatly appreciated!
P.S. I'm running Gitbash on Windows 10, but I tried to make sure that there are no Windows-specific characters. Maybe I'm mistaken.
the problem might be simpler than you overlooked?
I see on line (near yo dependency) you're missing a comma:
"webpack-dev-server": "^3.11.0"
"yo": "^3.1.1"
I suggest you add a comma, then try to run npm install again?
"webpack-dev-server": "^3.11.0",
"yo": "^3.1.1"
Dependencies:
"dependencies": {
"cors": "^2.8.5",
"firebase-admin": "^8.6.0",
"firebase-functions": "^3.11.0",
"nodemailer": "^6.4.11"
},
"devDependencies": {
"firebase-functions-test": "^0.1.6",
"tslint": "^5.12.0",
"typescript": "^3.2.2"
},
Description:
Since updating to firebase-functions 3.11.0, I get following error when trying to deploy my functions with firebase deploy --only functions:
node_modules/#types/jsdom/ts3.5/index.d.ts:8:24 - error TS2304: Cannot find name 'BigInt'.
8 BigInt: typeof BigInt;
~~~~~~
node_modules/#types/jsdom/ts3.5/index.d.ts:9:31 - error TS2304: Cannot find name 'BigInt64Array'.
9 BigInt64Array: typeof BigInt64Array;
~~~~~~~~~~~~~
node_modules/#types/jsdom/ts3.5/index.d.ts:10:32 - error TS2304: Cannot find name
'BigUint64Array'.
10 BigUint64Array: typeof BigUint64Array;
~~~~~~~~~~~~~~
Found 3 errors.
Even going back to the previous version doesn´t seem to solve the issue, so I´m not sure if the update was the trigger.
#edit 1 (full package.json)
{
"name": "functions",
"scripts": {
"lint": "tslint --project tsconfig.json",
"build": "tsc",
"serve": "npm run build && firebase serve --only functions",
"shell": "npm run build && firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"engines": {
"node": "10"
},
"main": "lib/index.js",
"dependencies": {
"cors": "^2.8.5",
"firebase-admin": "^8.6.0",
"firebase-functions": "^3.11.0",
"nodemailer": "^6.4.11"
},
"devDependencies": {
"firebase-functions-test": "^0.1.6",
"tslint": "^5.12.0",
"typescript": "^3.2.2"
},
"private": true
}
I think I have it. From npm #types/jsdom I went to package homepage where I found this part.
It seems that you need to install additional package:
npm install --save-dev #types/node
I have replicated this issue with firebase init and replacing package.json with yours. I got the same issue than. After package install with above command my function was deployed with no errors.
One remark: you do not have #types/jsdom in package.json, which according to my understanding should be there. I have installed this package before replacing the file, to have similar situation.
i have install prisma using
npm install -g prisma
but in my packaje.JSON file there is no such prisma configuration available ..what shoulkd i do?
package.json :
{
"name": "mysql-node",
"version": "1.0.0",
"description": "demo",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node db.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"#babel/core": "^7.0.0",
"apollo-server": "^2.5.0",
"apollo-server-express": "^2.5.0",
"axios": "^0.18.0",
"babel-preset-node5": "^12.0.1",
"express": "^4.16.4",
"graphql": "^14.3.0",
"graphql-tools": "^4.0.4",
"lodash": "^4.17.11",
"mysql": "^2.17.1",
"nodemailer": "^6.1.1",
"sequelize": "^5.8.7"
},
"devDependencies": {
"#babel/cli": "^7.0.0",
"#babel/core": "^7.4.5",
"#babel/node": "^7.4.5",
"#babel/preset-env": "^7.4.5"
}
}
TL;DR: run npm install prisma without the -g.
Explanations:
The command "npm install -g prisma" installs Prisma globally on your computer. This is useful so that you can run commands like prisma deploy directly in your terminal.
Installing Prisma as a dependency of your project (in package.json), will allow anyone cloning your project and running npm install to also download Prisma. However, you won't be able to access the command prisma deploy directly in your terminal, and you will need to put it in a script in package.json.
Eg:
{
...
scripts: {
"deploy": "prisma deploy"
}
...
}
And then npm run deploy
To install Prisma locally, simply run npm install prisma without the -g
I trying to dockerize my nodeJS api. Check out the following files :
.\package.json
{
"name": "test-api",
"version": "1.0.0",
"description": "TBD",
"scripts": {
"start": "node ./bin/www"
},
"keywords": [
"test",
"API"
],
"author": "test",
"dependencies": {
"bcrypt": "^2.0.1",
"bcrypt-promise": "^2.0.0",
"body-parser": "^1.18.3",
"debug": "^3.1.0",
"dotenv": "^6.0.0",
"express": "^4.16.3",
"jsonwebtoken": "^8.3.0",
"morgan": "^1.9.0",
"multer": "^1.3.1",
"mysql2": "^1.5.3",
"nodemailer": "^4.6.7",
"parse-error": "^0.2.0",
"passport": "^0.4.0",
"passport-jwt": "^4.0.0",
"sequelize": "^4.37.10",
"validator": "^10.4.0"
}
}
.\docker-compose.yml
version: '2'
services:
api:
build: .
ports:
- "4200:4200"
depends_on:
- db
environment:
- DATABASE_HOST=db
volumes:
- .:/usr/src/app
- /usr/src/app/node_modules
db:
build: ./db
.\Dockerfile
FROM node:8
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 4200
CMD [ "npm", "start" ]
.\db\Dockerfile
FROM mysql:latest
ENV MYSQL_ROOT_PASSWORD root
ENV MYSQL_DATABASE test_dev
ENV MYSQL_USER test-dev
ENV MYSQL_PASSWORD testapi
I get the following error when I do "docker-compose up"-
I'm pretty new to this, solution to solve this and few pointers on what to research more would help me a lot!
Try with this Dockerfile (avoid COPY *) and I recommend to use the absolute path in destination:
.\Dockerfile
FROM node:8
COPY package.json /usr/src/app
WORKDIR /usr/src/app
RUN npm install
COPY . .
EXPOSE 4200
CMD [ "npm", "start" ]
{
"name": "react-redux-starter-kit",
"version": "1.0.0",
"description": "This would be the starter kit for react projects.",
"main": "index.html",
"scripts": {
"start": "rm -rf build/ && rm -rf dist/ && webpack && webpack-dev-server --progress --colors",
"build": "rm -rf build/ && rm -rf dist/ && NODE_ENV=production webpack --config ./webpack.production.config.babel.js --progress"
},
"repository": {
"type": "git",
"url": "git+https://rahulshettyprdxn#bitbucket.org/rahulshettyprdxn/react-devops.git"
},
"keywords": [
"react",
"webpack",
"react-native"
],
"author": "Rahul Shetty",
"license": "MIT",
"homepage": "https://bitbucket.org/rahulshettyprdxn/react-devops#readme",
"devDependencies": {
"babel-core": "^6.5.2",
"babel-eslint": "^5.0.0",
"babel-loader": "^6.2.3",
"babel-plugin-react-transform": "^2.0.0",
"babel-preset-es2015-without-strict": "0.0.2",
"babel-preset-react": "^6.5.0",
"css-loader": "^0.23.1",
"eslint": "^2.2.0",
"eslint-plugin-react": "^4.1.0",
"extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.8.5",
"html-webpack-plugin": "^2.9.0",
"image-webpack-loader": "^1.6.3",
"node-sass": "^3.4.2",
"react-css-modules": "^3.7.5",
"react-transform-hmr": "^1.0.2",
"sass-loader": "^3.1.2",
"style-loader": "^0.13.0",
"webpack": "^1.12.14",
"webpack-dev-server": "^1.14.1"
},
"dependencies": {
"bootstrap": "^3.3.6",
"react": "^0.14.7",
"react-bootstrap": "^0.28.3",
"react-dom": "^0.14.7"
}
}
Below is the error that I am receiving:
Parsing error: Unexpected token at line 2 col 8 in Atom editor.
Note that I'm currently getting this error on Windows 10.
ESLint Version:
"eslint": "^2.2.0",
"eslint-plugin-react": "^4.1.0"
I have installed linter-eslint in my Atom editor and Global npm ESLint setting is off.
I am quite confused as the error message is not that descriptive. This in no way is hampering my project but I am quite inquisitive as to why I am getting this error in my editor.
ESLint is for validating JavaScript, not JSON.
From the website:
ESLint
The pluggable linting utility for JavaScript and JSX
[emphasis mine]
(You can try your code on the online demo here, and you get the same error)
If you want to use ESLint on a JSON file, you could use a package like eslint-plugin-json.