Build Command Failed

Here’s my build command in Render
npm run build

Here’s my package.json

"scripts": {
    "build": "grunt build",
}

I got this kind of fail deploy errors

May 19 01:39:53 PM  > grunt build
May 19 01:39:53 PM  
May 19 01:39:53 PM  grunt-cli: The grunt command line interface (v1.4.3)
May 19 01:39:53 PM  
May 19 01:39:53 PM  Fatal error: Unable to find local grunt.
May 19 01:39:53 PM  
May 19 01:39:53 PM  If you're seeing this message, grunt hasn't been installed locally to
May 19 01:39:53 PM  your project. For more information about installing and configuring grunt,
May 19 01:39:53 PM  please see the Getting Started guide:
May 19 01:39:53 PM  
May 19 01:39:53 PM  https://gruntjs.com/getting-started
May 19 01:39:53 PM  npm ERR! code ELIFECYCLE
May 19 01:39:53 PM  npm ERR! errno 99

Can someone help me?

I’m ex Heroku user btw, and it works fine without any issues.

Hi there,

Thanks for reaching out.

There’s not a lot to go one from those logs, the main issue is Fatal error: Unable to find local grunt.. Is there anything in the preceding logs showing any issues when trying to install the packages?

If you’re able to share some more specific details of the issue, we may help us troubleshoot it with you, e.g. any further logs/errors/output, service type/ID, reproduction steps, repo (if public), etc.

If you don’t want to share these details on the community forum, please feel free to raise a ticket with support@render.com

Kind regards

Alan

it seems like we can’t install global module in the build command
any suggestion or example?

Have you tried using npx? For example, npx grunt build

Alan

I’ve updated using npx, still no luck

package.json

"scripts": {
    "build": "npx grunt build",
}

error:

May 20 11:15:59 PM  yarn run v1.22.5
May 20 11:15:59 PM  $ npx grunt build
May 20 11:15:59 PM  grunt-cli: The grunt command line interface (v1.4.3)
May 20 11:15:59 PM  
May 20 11:15:59 PM  Fatal error: Unable to find local grunt.
May 20 11:15:59 PM  
May 20 11:15:59 PM  If you're seeing this message, grunt hasn't been installed locally to
May 20 11:15:59 PM  your project. For more information about installing and configuring grunt,
May 20 11:15:59 PM  please see the Getting Started guide:
May 20 11:15:59 PM  
May 20 11:15:59 PM  https://gruntjs.com/getting-started
May 20 11:15:59 PM  error Command failed with exit code 99.
May 20 11:15:59 PM  info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
May 20 11:15:59 PM  ==> Build failed 😞`

If you’re referring to service srv-ca2sor50mal3c4eo6jt0, it seems to use quite an old version of Node and I can only currently see yarn build as a build command.

It also appears you’ve been switching between different npm & yarn commands with each build. What do you use on your development environment? I’m also not seeing a lock file for your packages, which is worth ensuring is generated locally and committed to your repo.

If you use npm locally, I’d expect to see a build command something like: npm install; npm run build
And start commands of npm run start

However, these commands will depend on how you’ve implemented your project and which package manager you use.

Alan

Yes, that’s correct service.
I’ve updated using npm install; npm run build; but it keeps getting error:
using npx grunt build also doesn’t work

May 23 10:59:09 AM  > grunt build
May 23 10:59:09 AM  
May 23 10:59:09 AM  sh: 1: grunt: not found
May 23 10:59:09 AM  npm verb lifecycle xxx@0.0.0~build: unsafe-perm in lifecycle true
May 23 10:59:09 AM  npm verb lifecycle xxx@0.0.0~build: PATH: /opt/render/project/nodes/node-10.24.1/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/opt/render/project/src/node_modules/.bin:/opt/render/project/nodes/node-10.24.1/bin:/opt/render/project/src/node_modules/.bin:/opt/render/project/src/.venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
May 23 10:59:09 AM  npm verb lifecycle xxx@0.0.0~build: CWD: /opt/render/project/src
May 23 10:59:09 AM  npm info lifecycle xxx@0.0.0~build: Failed to exec build script
May 23 10:59:09 AM  npm verb stack Error: xxx@0.0.0 build: `grunt build`
May 23 10:59:09 AM  npm verb stack spawn ENOENT
May 23 10:59:09 AM  npm verb stack     at ChildProcess.<anonymous> (/opt/render/project/nodes/node-10.24.1/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:48:18)
May 23 10:59:09 AM  npm verb stack     at ChildProcess.emit (events.js:198:13)
May 23 10:59:09 AM  npm verb stack     at maybeClose (internal/child_process.js:982:16)
May 23 10:59:09 AM  npm verb stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
May 23 10:59:09 AM  npm verb pkgid xxx@0.0.0
May 23 10:59:09 AM  npm verb cwd /opt/render/project/src
May 23 10:59:09 AM  npm verb Linux 5.13.0-1023-aws
May 23 10:59:09 AM  npm verb argv "/opt/render/project/nodes/node-10.24.1/bin/node" "/opt/render/project/nodes/node-10.24.1/bin/npm" "run" "build" "--verbose"
May 23 10:59:09 AM  npm verb node v10.24.1
May 23 10:59:09 AM  npm verb npm  v6.14.12
May 23 10:59:09 AM  npm ERR! code ELIFECYCLE
May 23 10:59:09 AM  npm ERR! syscall spawn
May 23 10:59:09 AM  npm ERR! file sh
May 23 10:59:09 AM  npm ERR! errno ENOENT
May 23 10:59:09 AM  npm ERR! xxx@0.0.0 build: `grunt build`
May 23 10:59:09 AM  npm ERR! spawn ENOENT
May 23 10:59:09 AM  npm ERR!
May 23 10:59:09 AM  npm ERR! Failed at the xxx@0.0.0 build script.
May 23 10:59:09 AM  npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
May 23 10:59:09 AM  npm verb exit [ 1, true ]
May 23 10:59:09 AM  npm timing npm Completed in 250ms
May 23 10:59:09 AM  
May 23 10:59:09 AM  npm ERR! A complete log of this run can be found in:
May 23 10:59:09 AM  npm ERR!     /opt/render/.cache/_logs/2022-05-23T03_59_09_835Z-debug.log
May 23 10:59:09 AM  ==> Build failed 😞

Is grunt being installed? Is it listed in your package.json dependencies? Or maybe it’s listed in devDependencies? If it’s under devDependencies you might need to use the --production=false on your npm install command source

Alan

My bad, grunt was not declared in dependencies.
Thanks @al_ps !

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.