Faild on deployment on Heroku - javascript

I made an app with node.js +react but I can't deploy it on heroku.
It work on localal host
I tried to delete package-lock.json file but it doesn't help.
here is my scripts in package.json in server directory
"scripts": {
"start": "node index.js",
"server": "nodemon index.js",
"client": "npm run start --prefix client",
"dev": "concurrently \"npm run server\" \"npm run client\"",
"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client"
and my heroku logs
*
-----> Node.js app detected
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NODE_ENV=production
NODE_MODULES_CACHE=true
NODE_VERBOSE=false
-----> Installing binaries
engines.node (package.json): 8.1.1
engines.npm (package.json): 5.0.3
Resolving node version 8.1.1...
Downloading and installing node 8.1.1...
npm 5.0.3 already installed with node
-----> Restoring cache
- node_modules
-----> Installing dependencies
Installing node modules (package.json + package-lock)
added 93 packages in 7.456s
-----> Build
Running heroku-postbuild
> server#1.0.0 heroku-postbuild /tmp/build_52aeb2bcb298df1839239655d0215864
> NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client
> fsevents#1.2.9 install /tmp/build_52aeb2bcb298df1839239655d0215864/client/node_modules/jest-haste-map/node_modules/fsevents
> node install
> fsevents#1.2.9 install /tmp/build_52aeb2bcb298df1839239655d0215864/client/node_modules/chokidar/node_modules/fsevents
> node install
> core-js-pure#3.1.4 postinstall /tmp/build_52aeb2bcb298df1839239655d0215864/client/node_modules/core-js-pure
> node scripts/postinstall || echo "ignore"
> core-js#2.6.9 postinstall /tmp/build_52aeb2bcb298df1839239655d0215864/client/node_modules/babel-runtime/node_modules/core-js
> node scripts/postinstall || echo "ignore"
added 1550 packages in 43.208s
> client#0.1.0 build /tmp/build_52aeb2bcb298df1839239655d0215864/client
> react-scripts build
/tmp/build_52aeb2bcb298df1839239655d0215864/client/node_modules/#hapi/hoek/lib/deep-equal.js:17
options = { prototype: true, ...options };
^^^ SyntaxError: Unexpected token ...
at createScript (vm.js:74:10)
at Object.runInThisContext (vm.js:116:10)
at Module._compile (module.js:533:28)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/tmp/build_52aeb2bcb298df1839239655d0215864/client/node_modules/#hapi/hoek/lib/index.js:9:19)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Module.require (module.js:513:17) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! client#0.1.0 build: `react-scripts build`
npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the client#0.1.0
build 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!
/tmp/npmcache.1V3q7/_logs/2019-06-21T10_03_50_779Z-debug.log npm ERR!
code ELIFECYCLE npm ERR! errno 1 npm ERR! server#1.0.0
heroku-postbuild: NPM_CONFIG_PRODUCTION=false npm install --prefix
client && npm run build --prefix client npm ERR! Exit status 1 npm
ERR! npm ERR! Failed at the server#1.0.0 heroku-postbuild 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!
/tmp/npmcache.1V3q7/_logs/2019-06-21T10_03_50_793Z-debug.log
-----> Build failed
We're sorry this build is failing! You can troubleshoot common issues here:
https://devcenter.heroku.com/articles/troubleshooting-node-deploys
If you're stuck, please submit a ticket so we can help:
https://help.heroku.com/
Love,
Heroku
! Push rejected, failed to compile Node.js app. ! Push failed*

You do not required to delete the package.json file. You just have to upload all the files and folder excepting node_modules. Heroku server install all required packages for you.
One more thing, you have to add "test" command under the scripts tag.
"scripts": {
"test": "node index.js",
"start": "node index.js"
},

Related

Running next build gives "Error. Could not find a valid built in the '.next' build directory"

Running next build (via npm run build) on my remote machine hosting my web app with Next#8.1.0 yields no issues.
Locally I've updated to Next#9.1.3 (in fact, I've been experimenting with various versions to try and fix this issue), running next build gives:
➜ src git:(master) ✗ npm run build
> # build /Users/zavide/WebDev/workspace/src
> next build
> Build error occurred
Error: Could not find a valid build in the '/Users/zavide/WebDev/workspace/src/.next' directory! Try building your app with 'next build' before starting the server.
at Server.readBuildId (/Users/zavide/WebDev/workspace/src/node_modules/next/dist/next-server/server/next-server.js:563:23)
at new Server (/Users/zavide/WebDev/workspace/src/node_modules/next/dist/next-server/server/next-server.js:48:29)
at createServer (/Users/zavide/WebDev/workspace/src/node_modules/next/dist/server/next.js:2:133)
at Object.<anonymous> (/Users/zavide/WebDev/workspace/src/server.js:8:16)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! # build: `next build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the # build 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! /Users/zavide/.npm/_logs/2019-11-09T17_40_34_709Z-debug.log
package.json looks like this btw:
{
"scripts": {
"next": "next",
"build": "next build",
"start": "next start",
"prod": "NODE_ENV=production node server.js",
"test": "mocha"
},
...
This has been driving me nuts. How was I able to generate builds before (and still am on my remote machine) and now I suddenly can't? How am I supposed to run next build when I can't bloody run next build LMAO. Without a build directory, I can't run any production code.

Confluence "Hello World" Macro help - NPM install/start not working

I am trying to make my first confluence macro and I am following the instructions laid out here:https://developer.atlassian.com/cloud/confluence/getting-started/?_ga=2.78735767.2027190294.1547046060-2004234667.1546438516
Currently, I am having trouble with steps 2 and 4; NPM install and NPM start:
Received the following errors:
➜ ~ cd confluence_app
➜ confluence_app
➜ confluence_app ls
confluence-helloworld-addon credentials.json package-lock.json
➜ confluence_app ls
confluence-helloworld-addon
➜ confluence_app cd confluence-helloworld-addon
➜ confluence-helloworld-addon git:(master) npm install package.json
npm notice created a lockfile as package-lock.json. You should commit this file.
+ package.json#2.0.1
added 74 packages from 35 contributors and audited 162 packages in 29.12s
found 0 vulnerabilities
➜ confluence-helloworld-addon git:(master) ✗ npm start
> helloworld-addon#0.0.1 start /Users/serdarmustafa/confluence_app/confluence-helloworld-addon
> node app.js
internal/modules/cjs/loader.js:583
throw err;
^
Error: Cannot find module 'express'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (/Users/serdarmustafa/confluence_app/confluence-helloworld-addon/app.js:6:15)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! helloworld-addon#0.0.1 start: `node app.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the helloworld-addon#0.0.1 start 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! /Users/serdarmustafa/.npm/_logs/2019-01-12T09_26_18_269Z-debug.log
run npm cache clean --force first, and then run npm install, then npm start
this should fix it..
--
OR delete the node_modules folder and re-run npm install
--
OR
1. npm cache clean --force
delete node_modules and package-lock.json,
npm install

Unable to run server and error displayed in command prompt

I am trying to open the web page with the code followed in github and unable to run the server facing the errors and displayed in command prompt as below:
Code link: https://github.com/mschwarzmueller/nodejs-basics-tutorial/tree/master/09-mongodb
Error:
05-express-first-app#0.0.0 start C:\Users\Atchaya\Downloads\nodejs-basics-tutorial-master\09-mongodb
node ./bin/www
module.js:471
throw err;
^
Error: Cannot find module 'express'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Users\Atchaya\Downloads\nodejs-basics-tutorial-master\09-mongodb\app.js:1:77)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! 05-express-first-app#0.0.0 start: `node ./bin/www`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the 05-express-first-app#0.0.0 start script 'node ./bin/www'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the 05-express-first-app package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node ./bin/www
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs 05-express-first-app
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls 05-express-first-app
npm ERR! There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Atchaya\AppData\Roaming\npm-cache\_logs\2017-04-19T14_14_54_505Z-debug.log
Go you your 09-mongodb folder, then run npm install command, then run npm run start.
npm install -
This command installs a package, and any packages that it depends on.
If the package has a shrinkwrap file, the installation of dependencies
will be driven by that.
By default, npm install will install all modules listed as
dependencies in package.json.

How to properly use local paths in NPM and require method in Node.js

I'm having an issue trying to clean up some code.
Here is the portion of code where I am trying to import certain files from the pageObject directory, these LOC are in all my test files:
var config = require('../../../../adminVariables');
var AdminLogin = require('../../../../pageObject/admin/login/index');
var HeaderProfile = require('../../../../pageObject/admin/login/common/headerProfile/index');
var AccountSettings = require('../../../../pageObject/admin/login/accountSettings/index');
adminVariables and index are both javascript files.
It looks very ugly and I want to minimize it to make it more readable and elegant by reducing all the ../../../ (also my boss doesn't like it).
I've tried following the NPM docs found here: https://docs.npmjs.com/files/package.json#local-paths
but I'm slightly confused about using npm install --save. My page object directories do not have package.json files in them. Just simple js files that create classes and methods that I reference in my tests scripts. I get this error:
npm ERR! eisdir EISDIR: illegal operation on a directory, read
npm ERR! eisdir This is most likely not a problem with npm itself
npm ERR! eisdir and is related to npm not being able to find a package.json in
npm ERR! eisdir a package you are trying to install.
I thought maybe I can do it manually such as altering my package.json as:
{
"dependencies": {
"admin-variables": "file:./qe/adminVariables",
"admin-login": "file:./qe/pageObject/admin/login/index",
"header-profile": "file:./qe/pageObject/admin/login/common/headerProfile/index",
"account-settings": "file:./qe/pageObject/admin/login/accountSettings/index"
}
}
Then change the previous LOC to this:
var config = require('admin-variables');
var AdminLogin = require('admin-login');
var HeaderProfile = require('header-profile');
var AccountSettings = require('account-settings');
But when I try to run my test scripts I get the following error:
module.js:340
throw err;
^
Error: Cannot find module 'admin-variables'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:289:25)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (/Users/username/go/src/bitbucket.org/companyname/platform/qe/test/admin/dashboard/adminUser/pdvi-2361.js:7:14)
at Module._compile (module.js:425:26)
at Object.Module._extensions..js (module.js:432:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at /Users/username/go/src/bitbucket.org/companyname/platform/qe/node_modules/mocha/lib/mocha.js:216:27
at Array.forEach (native)
at Mocha.loadFiles (/Users/username/go/src/bitbucket.org/companyname/platform/qe/node_modules/mocha/lib/mocha.js:213:14)
at Mocha.run (/Users/username/go/src/bitbucket.org/companyname/platform/qe/node_modules/mocha/lib/mocha.js:453:10)
at Object.<anonymous> (/Users/username/go/src/bitbucket.org/companyname/platform/qe/node_modules/mocha/bin/_mocha:393:18)
at Module._compile (module.js:425:26)
at Object.Module._extensions..js (module.js:432:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at Function.Module.runMain (module.js:457:10)
at startup (node.js:138:18)
at node.js:974:3
npm ERR! Darwin 15.2.0
npm ERR! argv "/usr/local/Cellar/node/5.1.1/bin/node" "/usr/local/bin/npm" "run" "env-production" "mocha" "test/admin/dashboard/adminUser/pdvi-2361.js" "--" "--reporter" "spec" "--slow" "0"
npm ERR! node v5.1.1
npm ERR! npm v3.5.2
npm ERR! code ELIFECYCLE
npm ERR! ui-tests#1.0.0 env-production: `env envVar='production' "mocha" "test/admin/dashboard/adminUser/pdvi-2361.js" "--reporter" "spec" "--slow" "0"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ui-tests#1.0.0 env-production script 'env envVar='production' "mocha" "test/admin/dashboard/adminUser/pdvi-2361.js" "--reporter" "spec" "--slow" "0"'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the ui-tests package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! env envVar='production' "mocha" "test/admin/dashboard/adminUser/pdvi-2361.js" "--reporter" "spec" "--slow" "0"
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs ui-tests
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls ui-tests
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/username/go/src/bitbucket.org/companyname/platform/qe/npm-debug.log
npm ERR! Darwin 15.2.0
npm ERR! argv "/usr/local/Cellar/node/5.1.1/bin/node" "/usr/local/bin/npm" "run" "p-2361:spec"
npm ERR! node v5.1.1
npm ERR! npm v3.5.2
npm ERR! code ELIFECYCLE
npm ERR! ui-tests#1.0.0 p-2361:spec: `npm run env-production mocha test/admin/dashboard/adminUser/pdvi-2361.js -- --reporter spec --slow 0`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ui-tests#1.0.0 p-2361:spec script 'npm run env-production mocha test/admin/dashboard/adminUser/pdvi-2361.js -- --reporter spec --slow 0'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the ui-tests package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! npm run env-production mocha test/admin/dashboard/adminUser/pdvi-2361.js -- --reporter spec --slow 0
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs ui-tests
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls ui-tests
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/username/go/src/bitbucket.org/companyname/platform/qe/npm-debug.log
Here is my directory structure that I work in (mostly qe/ folder).
platform/
qe/
node_modules/
pageObject/
admin/
login/
accountSettings/
index.js
common/
headerProfile/
index.js
dashboard/
index.js
index.js
test/
admin/
dashboard/
adminUser/
pdvi-2361.js
pdvi-2372.js
pdvi-2377.js
adminVariables.json
package.json
Here is an example of what my page object looks like:
var webdriver = require('selenium-webdriver');
var config = require('../../../adminVariables');
var adminVar = process.env.envVar;
var login = config[adminVar].adminLogin;
var user = config[adminVar].role.adminUser.name;
var email = config[adminVar].role.adminUser.email;
var pw = config[adminVar].role.adminUser.password;
class AdminLogin {
constructor(driver) {
this.driver = driver;
this.driver.manage().timeouts().implicitlyWait(2000);
this.emailField = this.driver.findElement({
css: 'input[name="email"]'
});
this.passwordField = this.driver.findElement({
css: 'input[name="password"]'
});
this.loginButton = this.driver.findElement({
css: 'button[type="submit"]'
});
}
fillEmail(email) {
this.emailField.sendKeys(email);
}
fillPassword(password) {
this.passwordField.sendKeys(password);
}
signin() {
this.loginButton.click();
}
}
module.exports = AdminLogin;
What would be the proper way to require these local json/javascript files in my code?

Gulp.js trouble installing, cannot find module 'fetch.js'?

I did an npm install and it generated a node_modules folder on my folder with only a gulp-livereload subfolder in it. My package.json has the following devDependencies:
.....
"devDependencies": {
"gulp": "^3.8.8",
"gulp-livereload": "^2.1.1"
}
}
When doing npm install/update, it is not generating the gulp folder and also giving me the error message:
> v8flags#1.0.1 install C:\Users\SLowe\node_modules\gulp\node_modules\v8flags
> node fetch.js
module.js:340
throw err;
^
Error: Cannot find module 'C:\Users\SYoung\fetch.js'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3
npm ERR! v8flags#1.0.1 install: `node fetch.js`
npm ERR! Exit status 8
npm ERR!
npm ERR! Failed at the v8flags#1.0.1 install script.
npm ERR! This is most likely a problem with the v8flags package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node fetch.js
npm ERR! You can get their info via:
npm ERR! npm owner ls v8flags
npm ERR! There is likely additional logging output above.
npm ERR! System Windows_NT 6.2.9200
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js"
"install" "--save-dev" "gulp"
npm ERR! cwd C:\Users\SYoung
npm ERR! node -v v0.10.32
npm ERR! npm -v 1.4.28
npm ERR! code ELIFECYCLE
npm ERR! not ok code 0
Any help is appreciated. I am very new to nodejs.
It seems that the new gulp release (3.8.9) isn't compatible with v8flags. Try changing the package.json to
.....
"devDependencies": {
"gulp": "3.8.8",
"gulp-livereload": "^2.1.1"
}
}
If 3.8.8 doesn't work, 3.8.7 worked for me.
Yes, changing gulp to 3.8.8 helped me too.
I also installed gulp 3.8.8 and everything is now working fine.
npm install -g gulp#3.8.8
npm install gulp#3.8.8

Categories