Error with deploy function to Firebase - javascript

I'm trying to deploy function to Firebase
$ npm install firebase-tools
$ login firebase
$ firebase init functions
then $firebase deploy --only functions or $firebase deploy
package.json:
{
"name": "functions",
"description": "Cloud Functions for Firebase",
"scripts": {
"lint": "eslint .",
"serve": "firebase serve --only functions",
"shell": "firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"dependencies": {
"firebase-admin": "~5.12.1",
"firebase-functions": "^1.0.3"
},
"devDependencies": {
"eslint": "^4.12.0",
"eslint-plugin-promise": "^3.6.0"
},
"private": true
}
firebase.json:
{
"functions": {
"predeploy": [
"npm --prefix \"%RESOURCE_DIR%\" run lint"
]
}
}
edited with $RESOURCE_DIR as %RESOURCE_DIR% to avoid:
Error: functions predeploy error: Command terminated with non-zero
exit code4294963238
my function index.js:
const functions = require('firebase-functions');
var admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
var wrotedata;
exports.Pushtrigger = functions.database.ref('/messages/{messageId}').onWrite((event) => {
wrotedata = event.data.val();
admin.database().ref('/pushtokens').orderByChild('uid').once('value').then((alltokens) => {
var rawtokens = alltokens.val();
var tokens = [];
this.processtokens(rawtokens).then((processedtokens) => {
for (var token in processedtokens) {
tokens.push(token.devtoken);
}
var payload = {
"notification": {
"title": "Notification title",
"body": "Notification body",
"sound": "default",
"click_action": "FCM_PLUGIN_ACTIVITY",
"icon": "fcm_push_icon"
},
"data": {
"message": "value1",
"sendername": "value2"
}
}
return admin.messaging().sendToDevice(tokens, payload).then((response) => {
console.log('Push notifications');
}).catch((err) => {
console.log(err);
})
})
})
})
function processtokens(rawtokens) {
var promise = new Promise((resolve, reject) => {
var processedtokens = []
for (token in rawtokens) {
processedtokens.push(rawtokens[token]);
}
resolve(processdatatokens);
})
return promise;
}
I've tried:
npm install firebase-admin#latest firebase-functions#latest
npm install -g git://github.com/firebase/firebase-tools#master
but I got:
Error: functions predeploy error: Command terminated with non-zero
exit code1
2018-07-12T23_38_09_788Z-debug:
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli '--prefix',
1 verbose cli 'C:\\Users\\User\\Desktop\\pushcloud\\functions',
1 verbose cli 'run',
1 verbose cli 'lint' ]
2 info using npm#5.6.0
3 info using node#v8.9.4
4 verbose run-script [ 'prelint', 'lint', 'postlint' ]
5 info lifecycle functions#~prelint: functions#
6 info lifecycle functions#~lint: functions#
7 verbose lifecycle functions#~lint: unsafe-perm in lifecycle true
8 verbose lifecycle functions#~lint: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\User\Desktop\pushcloud\functions\node_modules\.bin;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Embarcadero\Studio\16.0\bin;C:\Users\Public\Documents\Embarcadero\Studio\16.0\Bpl;C:\Program Files (x86)\Embarcadero\Studio\16.0\bin64;C:\Users\Public\Documents\Embarcadero\Studio\16.0\Bpl\Win64;C:\Inprise\vbroker\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Python27;C:\Python27\Scripts\;C:\Users\User\AppData\Local\Programs\Python\Python35-32;C:\Users\User\AppData\Local\Programs\Python\Python35-32\Scripts;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Emgu\emgucv-windesktop 3.1.0.2282\bin\x86;C:\Program Files (x86)\Skype\Phone\;C:\php;C:\Apache2;C:\Apache2\bin;C:\Program Files\dotnet\;C:\WINDOWS\system32\config\systemprofile\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Java\jdk1.8.0_151\bin;C:\Users\User\AppData\Local\Android\Sdk\platform-tools;C:\Program Files\nodejs\;C:\Program Files\Git\cmd;C:\Program Files\Git\usr\bin;C:\Go\bin;C:\Program Files (x86)\Java\jre1.8.0_101\bin;C:\Users\User\AppData\Local\Programs\Python\Python35-32\Scripts\;C:\Users\User\AppData\Local\Programs\Python\Python35-32\;C:\Users\User\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Microsoft VS Code\bin;C:\Users\User\AppData\Roaming\npm;C:\Users\User\go\bin
9 verbose lifecycle functions#~lint: CWD: C:\Users\User\Desktop\pushcloud\functions
10 silly lifecycle functions#~lint: Args: [ '/d /s /c', 'eslint .' ]
11 silly lifecycle functions#~lint: Returned: code: 1 signal: null
12 info lifecycle functions#~lint: Failed to exec lint script
13 verbose stack Error: functions# lint: `eslint .`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:285:16)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at EventEmitter.emit (events.js:214:7)
13 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at ChildProcess.emit (events.js:214:7)
13 verbose stack at maybeClose (internal/child_process.js:925:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid functions#
15 verbose cwd C:\Users\User\Desktop\pushcloud
16 verbose Windows_NT 10.0.16299
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "--prefix" "C:\\Users\\User\\Desktop\\pushcloud\\functions" "run" "lint"
18 verbose node v8.9.4
19 verbose npm v5.6.0
20 error code ELIFECYCLE
21 error errno 1
22 error functions# lint: `eslint .`
22 error Exit status 1
23 error Failed at the functions# lint script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
it looks like something wrong with code, because deploy of default Hello from Firebase! is successful
edit:
In case of edit in firebase.json form \"%RESOURCE_DIR%\" to "%RESOURCE_DIR%" error is
Error: There was an error loading firebase.json: Unexpected token '%'
"npm --prefix "%RESOURCE_DIR%" run lint"
If I remove line from firebase.json and run npm --prefix "%RESOURCE_DIR%" run lint in terminal:
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\User\Desktop\pushcloud\%RESOURCE_DIR%\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\User\AppData\Roaming\npm-cache\_logs\2018-07-13T11_33_25_593Z-debug.log
but directory folder exist as %RESOURCE_DIR% with folder etc, when package.json located in functions directory. If I relocate it to %RESOURCE_DIR%:
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! functions# lint: `eslint .`
npm ERR! Exit status 1
npm ERR! Failed at the functions# lint script.
npm ERR! This is probably not a problem with npm. 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\User\AppData\Roaming\npm-cache\_logs\2018-07-13T11_50_15_739Z-debug.log
and with $ firebase deploy --only functions:
C:\Users\User\Desktop\pushcloud\functions\index.js
9:5 error Expected catch() or return promise/catch-or-return
9:80 error Each then() should return a value or throw promise/always-return
12:9 error Expected catch() or return promise/catch-or-return
12:9 warning Avoid nesting promises promise/no-nesting
33:24 warning Avoid nesting promises promise/no-nesting
33:24 warning Avoid nesting promises promise/no-nesting
33:77 error Each then() should return a value or throw promise/always-return
✖ 7 problems (4 errors, 3 warnings)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! functions# lint: `eslint .`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the functions# lint 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\User\AppData\Roaming\npm-cache\_logs\2018-07-13T11_51_50_784Z-debug.log
Error: functions predeploy error: Command terminated with non-zero exit code1

Your predeploy flag npm --prefix \"%RESOURCE_DIR%\" run lint is causing your issues.
If you run npm --prefix "%RESOURCE_DIR%" run lint in your terminal, does it run correctly without error?
If you remove that line from your firebase.json then it should deploy without issue.
EDIT
Check the error message you're receiving, it has the answer for you. Your code linter is failing, and you'll need to fix those errors before you can deploy.
9:5 error Expected catch() or return promise/catch-or-return
9:80 error Each then() should return a value or throw promise/always-return
12:9 error Expected catch() or return promise/catch-or-return
12:9 warning Avoid nesting promises promise/no-nesting
33:24 warning Avoid nesting promises promise/no-nesting
33:24 warning Avoid nesting promises promise/no-nesting
33:77 error Each then() should return a value or throw promise/always-return
I've taken a quick look at your code, and I think I've cleaned it up. Additionally you didn't need to make processtokens a promise, it's a synchronous functions.
const functions = require('firebase-functions');
var admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
var wrotedata;
exports.Pushtrigger = functions.database.ref('/messages/{messageId}').onWrite((event) => {
wrotedata = event.data.val();
return admin.database().ref('/pushtokens')
.orderByChild('uid')
.once('value')
.then((alltokens) => {
var rawtokens = alltokens.val();
var tokens = [];
var processedtokens = this.processtokens(rawtokens);
for (var token in processedtokens) {
tokens.push(token.devtoken);
}
var payload = {
"notification": {
"title": "Notification title",
"body": "Notification body",
"sound": "default",
"click_action": "FCM_PLUGIN_ACTIVITY",
"icon": "fcm_push_icon"
},
"data": {
"message": "value1",
"sendername": "value2"
}
};
return admin.messaging().sendToDevice(tokens, payload).then((response) => {
console.log('Push notifications');
}).catch((err) => {
console.log(err);
})
})
})
function processtokens(rawtokens) {
var processedtokens = []
for (token in rawtokens) {
processedtokens.push(rawtokens[token]);
}
return processdatatokens;
}

Related

Cannot find module nodemon

My config.js file:
const config = {
development: {
PORT: 5000
},
production: {
PORT: 80
}
};
module.exports = config[process.env.NODE_ENV.trim()];
Here is my package.json:
"scripts": {
"start": "SET NODE_ENV=development && nodemon ./server.js",
"prod": "SET NODE_ENV=production && node ./server.js"
},
"dependencies": {
"express": "^4.17.1"
},
"devDependencies": {
"nodemon": "^2.0.12"
}
server.js file:
const config = require('./config/config');
app.listen(config.PORT, () => console.log(`Server is running on port ${config.PORT}...`));
The problem:
> cubicle#1.0.0 start C:\Users\stani\Documents\GitHub\Intro-to-JavaScript\Softuni\5. Back-end\3. ExpressJS & Templating\cubicle
> SET NODE_ENV=development && nodemon ./server.js
'Templating\cubicle\node_modules\.bin\' is not recognized as an internal or external command,
operable program or batch file.
internal/modules/cjs/loader.js:888
throw err;
^
Error: Cannot find module 'C:\Users\stani\Documents\GitHub\Intro-to-JavaScript\Softuni\5. Back-end\nodemon\bin\nodemon.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:885:15)
at Function.Module._load (internal/modules/cjs/loader.js:730:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! cubicle#1.0.0 start: `SET NODE_ENV=development && nodemon ./server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the cubicle#1.0.0 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! C:\Users\stani\AppData\Roaming\npm-cache\_logs\2021-08-10T16_07_01_722Z-debug.log
I tried installing it globally and other stuff I read on the internet but it sum down to this error, I don't understand what seems to be the problem.

Waiting for npm run-script build to complete before re-starting the server with nodejs/nodemon

I am serving my react app with a small express server.
When the server is running, I start a setInterval passing a function to check if my local copy is at the same point my remote repository is.
To check if my local and remote are equal, I am using the child_process from node to execute two git commands.
git rev-parse #
git ls-remote
If the hashes are not equal I will call a module to execute the build command.
Until this point, everything works perfectly. If my remote branch changes, my local code will get updated.
The problem is when I am building the app...
I update my code and when I am finished I will call the module that is responsible to re-build my app.
I am using exec from child_process from node and my function is returning a new promise.
That is the body of my function:
return new Promise((resolve, reject) => {
try{
exec(`npm run-script build`, async ( err, stdout, stderr ) => {
if ( err ) {
console.log( `Error trying to create build version: ${ err }` );
resolve(false)
}if ( stdout ){
console.log( `Building...: ${ stdout }` );
resolve(true)
}
else{
console.log( `Error trying to build application: ${ stderr }` );
resolve(false)
}
});
}catch( error ){
console.log('Command Error: ', error)
console.log( `Error trying to execute command build: ${ error }` );
reject(false)
}
})
Where the build function is called I have:
await buildApp()
But it isn't waiting for the build to be completed or when the build gets called, I get an error
npm ERR! code ELIFECYCLE
That is the log
9 verbose lifecycle #private/project#1.0.1~build: CWD: F:\Working\project\client\Frontend
10 silly lifecycle #private/project#1.0.1~build: Args: [ '/d /s /c', 'react-scripts build' ]
11 silly lifecycle #private/project#1.0.1~build: Returned: code: 1 signal: null
12 info lifecycle #private/project#1.0.1~build: Failed to exec build script
13 verbose stack Error: #private/project#1.0.1 build: react-scripts build
13 verbose stack Exit status 1
13 verbose stack at EventEmitter. (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:301:16)
13 verbose stack at EventEmitter.emit (events.js:189:13)
13 verbose stack at ChildProcess. (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:189:13)
13 verbose stack at maybeClose (internal/child_process.js:970:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
14 verbose pkgid #private/project#1.0.1
15 verbose cwd F:\Working\project\client\Frontend
16 verbose Windows_NT 10.0.17134
17 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "run-script" "build"
18 verbose node v10.15.3
19 verbose npm v6.4.1
20 error code ELIFECYCLE
21 error errno 1

Cannot deploy google cloud functions (error: ELIFECYCLE)

This problem is only introduce when adding a new cloud function using puppeteer. The error does not ooccur in local mode using 'firebase serve' only when trying to push it to google cloud functions. This cloud function is the beginning to a bigger project but I wanted to test if I could do the basics on local before live and this is the error im receiving in my logs at the bottom of the page.
I've tried exporting the api routes with just (app) then by making a required path.
const functions = require('firebase-functions');
const app = require('express')();
const puppeteer = require('puppeteer');
const { benchmark } = require('./handlers/benchmark');
// Runs before every route. Launches headless Chrome.
app.all('*', async (req, res, next) => {
// Note: --no-sandbox is required in this env.
// Could also launch chrome and reuse the instance
// using puppeteer.connect()
res.locals.browser = await puppeteer.launch({
args: ['--no-sandbox']
});
next(); // pass control to next route.
});
// Handler to take screenshots of a URL.
app.get('/benchmark', benchmark);
// Tried this first
exports.api = functions.https.onRequest(app);
// Tried this second
exports.api = functions.https.onRequest((req, res) => {
if (!req.path) {
req.url = `/${req.url}`;
}
return app(req, res);
});
My benchmark file:
exports.benchmark = async function screenshotHandler(req, res) {
// const url = '/';
// req.query.url
// if (!url) {
// return res
// .status(400)
// .send('Please provide a URL. Example: ?url=https://example.com');
// }
const browser = res.locals.browser;
try {
const page = await browser.newPage();
await page.goto('https://www.google.com', {
waitUntil: 'networkidle2'
});;
const buffer = await page.screenshot({ fullPage: true });
await res.type('image/png').send(buffer);
} catch (e) {
res.status(500).send(e.toString());
}
await browser.close();
};
Logs:
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Users\\bradley_ch\\tools\\node-v10.15.1-win-x64\\node.exe',
1 verbose cli 'C:\\Users\\bradley_ch\\tools\\node-v10.15.1-win-x64\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli '--prefix',
1 verbose cli 'C:\\Users\\bradley_ch\\OneDrive\\Production\\Benchmarking\\reactApp\\functions',
1 verbose cli 'run',
1 verbose cli 'lint' ]
2 info using npm#6.4.1
3 info using node#v10.15.1
4 verbose run-script [ 'prelint', 'lint', 'postlint' ]
5 info lifecycle functions#~prelint: functions#
6 info lifecycle functions#~lint: functions#
7 verbose lifecycle functions#~lint: unsafe-perm in lifecycle true
8 verbose lifecycle functions#~lint: PATH: C:\Users\bradley_ch\tools\node-v10.15.1-win-x64\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\bradley_ch\OneDrive\Production\Benchmarking\reactApp\functions\node_modules\.bin;C:\Program Files (x86)\RSA SecurID Token Common;c:\Oracle11g\instantclient_11_2;C:\ProgramData\Oracle\Java\javapath;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Sybase\Shared\PowerBuilder\;C:\Users\bradley_ch\AppData\Local\Programs\Python\Python37-32\Scripts\;C:\Users\bradley_ch\AppData\Local\Programs\Python\Python37-32\;C:\Users\bradley_ch\AppData\Local\Programs\Python\Launcher\;C:\Users\bradley_ch\AppData\Local\Microsoft\WindowsApps;C:\Users\bradley_ch\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\bradley_ch\tools\node-v10.15.1-win-x64;C:\Users\bradley_ch\Desktop\Casper\bin;C:\Users\bradley_ch\AppData\Local\Programs\Git\cmd
9 verbose lifecycle functions#~lint: CWD: C:\Users\bradley_ch\OneDrive\Production\Benchmarking\reactApp\functions
10 silly lifecycle functions#~lint: Args: [ '/d /s /c', 'eslint .' ]
11 silly lifecycle functions#~lint: Returned: code: 1 signal: null
12 info lifecycle functions#~lint: Failed to exec lint script
13 verbose stack Error: functions# lint: `eslint .`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (C:\Users\bradley_ch\tools\node-v10.15.1-win-x64\node_modules\npm\node_modules\npm-lifecycle\index.js:301:16)
13 verbose stack at EventEmitter.emit (events.js:189:13)
13 verbose stack at ChildProcess.<anonymous> (C:\Users\bradley_ch\tools\node-v10.15.1-win-x64\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:189:13)
13 verbose stack at maybeClose (internal/child_process.js:970:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
14 verbose pkgid functions#
15 verbose cwd C:\Users\bradley_ch\OneDrive\Production\Benchmarking\reactApp
16 verbose Windows_NT 10.0.16299
17 verbose argv "C:\\Users\\bradley_ch\\tools\\node-v10.15.1-win-x64\\node.exe" "C:\\Users\\bradley_ch\\tools\\node-v10.15.1-win-x64\\node_modules\\npm\\bin\\npm-cli.js" "--prefix" "C:\\Users\\bradley_ch\\OneDrive\\Production\\Benchmarking\\reactApp\\functions" "run" "lint"
18 verbose node v10.15.1
19 verbose npm v6.4.1
20 error code ELIFECYCLE
21 error errno 1
22 error functions# lint: `eslint .`
22 error Exit status 1
23 error Failed at the functions# lint script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
12 info lifecycle functions#~lint: Failed to exec lint script
13 verbose stack Error: functions# lint: `eslint .`
The system does not have or does not know where or what eslint is.
Install it, use absolute path or make your application respect %PATH%.

How to execute build script react js

I'm attempting to build a webpack/react project, however I'm not entirely sure on how or why this project is erroring...
Command line suggests that my npm/node might be outdated, but I just downloaded the stuff yesterday so I don't think that's the problem. New with react, appreciate all the help!
package.json: (Error comes from npm run build, doesn't seem to like --config)
{
"name": "annandale-bbsb",
"version": "1.0.0",
"description": "annandale baseball/softball website",
"main": "index.js",
"scripts": {
"build": "webpack",
"start": "webpack-dev-server"
},
"author": "Riley",
"license": "ISC",
"dependencies": {
"react": "^15.6.1",
"react-dom": "^15.6.1"
},
"devDependencies": {
"babel-core": "^6.25.0",
"babel-loader": "^7.1.0",
"babel-preset-react": "^6.24.1",
"html-webpack-plugin": "^2.28.0",
"webpack": "^3.0.0",
"webpack-dev-server": "^2.5.0"
}
}
webpack.config.js:
var HTMLWebpackPlugin = require('html-webpack-plugin');
var HTMLWebpackPluginConfig = new HTMLWebpackPlugin(
{
template: __dirname + '/app/index.html',
filename: 'index.html',
inject: 'body'
});
module.exports =
{
entry: __dirname + '/app/index.js',
module:
{
loaders:
[{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader'
}]
},
output:
{
filename: 'transformed.js',
path: __dirname + '/build/'
},
plugins: [HTMLWebpackPluginConfig]
};
This generates this npm-debug.log:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'build' ]
2 info using npm#3.10.10
3 info using node#v6.11.0
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle annandale-bbsb#1.0.0~prebuild: annandale-bbsb#1.0.0
6 silly lifecycle annandale-bbsb#1.0.0~prebuild: no script for prebuild, continuing
7 info lifecycle annandale-bbsb#1.0.0~build: annandale-bbsb#1.0.0
8 verbose lifecycle annandale-bbsb#1.0.0~build: unsafe-perm in lifecycle true
9 verbose lifecycle annandale-bbsb#1.0.0~build: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/Users/Riley/annandale-bbsb/node_modules/.bin:/Users/Riley/Library/Enthought/Canopy_64bit/User/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
10 verbose lifecycle annandale-bbsb#1.0.0~build: CWD: /Users/Riley/annandale-bbsb
11 silly lifecycle annandale-bbsb#1.0.0~build: Args: [ '-c', 'webpack' ]
12 silly lifecycle annandale-bbsb#1.0.0~build: Returned: code: 2 signal: null
13 info lifecycle annandale-bbsb#1.0.0~build: Failed to exec build script
14 verbose stack Error: annandale-bbsb#1.0.0 build: `webpack —-config webpack.config.js`
14 verbose stack Exit status 2
14 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:255:16)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at EventEmitter.emit (events.js:191:7)
14 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at ChildProcess.emit (events.js:191:7)
14 verbose stack at maybeClose (internal/child_process.js:891:16)
14 verbose stack at Process.ChildProcess._handle.onexit(internal/child_process.js:226:5)
15 verbose pkgid annandale-bbsb#1.0.0
16 verbose cwd /Users/Riley/annandale-bbsb
17 error Darwin 15.6.0
18 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "build"
19 error node v6.11.0
20 error npm v3.10.10
21 error code ELIFECYCLE
22 error annandale-bbsb#1.0.0 build: `webpack —-config webpack.config.js`
22 error Exit status 2
23 error Failed at the annandale-bbsb#1.0.0 build script 'webpack —-config webpack.config.js'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the annandale-bbsb package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error webpack —-config webpack.config.js
23 error You can get information on how to open an issue for this project with:
23 error npm bugs annandale-bbsb
23 error Or if that isn't available, you can get their info via:
23 error npm owner ls annandale-bbsb
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]

Npm ERR! Missing Script: Start when deploying to heroku

I do have a procfile:
web: node server.js
here's my package.json:
{
"name": "easyrtc_server_example",
"version": "0.1.6",
"author": "Priologic Software Inc. info#priologic.com (http://priologic.com/)",
"description" : "Simple EasyRTC server example which includes EasyRTC, Express, and Socket.io",
"main":"server.js",
"private": true,
"scripts": {
"start": "node server.js"
},
"dependencies" : {
"express": "^4.10.7",
"serve-static": "^1.8.0",
"socket.io": "^1.4.5",
"bcryptjs": "",
"body-parser": "",
"connect-flash": "",
"cookie-parser": "^1.4.1",
"express-handlebars": "",
"express-messages": "",
"express-session": "",
"express-validator": "",
"mongodb": "",
"mongoose": "",
"passport": "",
"passport-http": "",
"passport-local": ""
},
"license": "BSD2",
"engines": {
"node": ">=0.8"
}
}
Here's my npm-error log.
0 info it worked if it ends with ok
1 verbose cli [ 'C:\Program Files\nodejs\node.exe',
1 verbose cli 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js',
1 verbose cli 'start' ]
2 info using npm#3.10.10
3 info using node#v6.10.2
4 verbose stack Error: missing script: start
4 verbose stack at run (C:\Program Files\nodejs\node_modules\npm\lib\run-script.js:151:19)
4 verbose stack at C:\Program Files\nodejs\node_modules\npm\lib\run-script.js:61:5
4 verbose stack at C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:356:5
4 verbose stack at checkBinReferences_ (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:320:45)
4 verbose stack at final (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:354:3)
4 verbose stack at then (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:124:5)
4 verbose stack at C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:243:12
4 verbose stack at C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\graceful-fs.js:78:16
4 verbose stack at tryToString (fs.js:456:3)
4 verbose stack at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:443:12)
5 verbose cwd C:\Users\Nette\Desktop\pektos_1
6 error Windows_NT 6.3.9600
7 error argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "start"
8 error node v6.10.2
9 error npm v3.10.10
10 error missing script: start
11 error If you need help, you may report this error at:
11 error https://github.com/npm/npm/issues
12 verbose exit [ 1, true ]
help me guys please :(
Maybe it is too simple but did you try to make a "Procfile" file instead of just "procfile" with an uppercase P
maybe it's very late but if someone encounter this kind of problem like mine here's what i did on my procfile
worker: node server.js
thats what i did.
I had the same issue, and this error was because i was in the incorrect folder, i had to up a level and ran again npm start and it worked

Categories