Skip to content

Improve error message when dependencies installation fails #815

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/build/src/plugins/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const resolvePlugin = async function({ package, ...pluginOptions }, baseDir) {
// `resolve`
} catch (error) {
logResolveError(error, package)
await addDependency(package, { packageRoot: baseDir, stdio: 'ignore' })
await addDependency(package, { packageRoot: baseDir })
return await tryResolvePlugin(package, pluginOptions, baseDir)
}
}
Expand Down
12 changes: 10 additions & 2 deletions packages/build/src/utils/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,16 @@ const installDependencies = async function(packageRoot) {
}

// Add new Node.js dependencies
const addDependency = async function(packageName, { packageRoot, stdio }) {
await execa.command(`npm install --no-progress --no-audit --no-fund ${packageName}`, { cwd: packageRoot, stdio })
const addDependency = async function(packageName, { packageRoot }) {
try {
await execa.command(`npm install --no-progress --no-audit --no-fund ${packageName}`, {
cwd: packageRoot,
all: true,
})
} catch (error) {
const errorA = new Error(`Error while installing dependencies in ${packageRoot}\n${error.all}`)
throw errorA
}
}

module.exports = { installDependencies, addDependency }
Binary file modified packages/build/tests/config/load/snapshots/tests.js.snap
Binary file not shown.
Binary file modified packages/build/tests/config/normalize/snapshots/tests.js.snap
Binary file not shown.
Binary file modified packages/build/tests/config/template/snapshots/tests.js.snap
Binary file not shown.
47 changes: 0 additions & 47 deletions packages/build/tests/config/validate/snapshots/tests.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -698,53 +698,6 @@ Generated by [AVA](https://ava.li).
└─────────────────────────────┘␊
`

## plugins.any.type renamed

> Snapshot 1

`␊
> Starting Netlify Build v1.0.0␊
https://github.com/netlify/build␊
> Flags␊
{ config: '/file/path' }␊
> Current directory␊
/file/path␊
> Config file␊
/file/path␊
Configuration property plugins[0].type has been renamed to "package".␊
Invalid syntax␊
plugins:␊
- type: /file/path␊
Valid syntax␊
plugins:␊
- enabled: true␊
package: /file/path␊
Error: '/file/path' plugin not installed or found.␊
Please install it with npm or yarn.␊
Cannot find module '/file/path' from '/file/path'␊
┌─────────────────────────────┐␊
│ Netlify Build Error │␊
└─────────────────────────────┘␊
Error: Command failed with exit code 1: npm install --no-progress --no-audit --no-fund /file/path␊
STACK TRACE␊
┌─────────────────────────────┐␊
│ END Netlify Build Error │␊
└─────────────────────────────┘␊
`

## plugins.any: unknown property

> Snapshot 1
Expand Down
Binary file modified packages/build/tests/config/validate/snapshots/tests.js.snap
Binary file not shown.
Binary file modified packages/build/tests/core/cli/snapshots/tests.js.snap
Binary file not shown.
Binary file modified packages/build/tests/core/commands/snapshots/tests.js.snap
Binary file not shown.
Binary file modified packages/build/tests/core/error/snapshots/tests.js.snap
Binary file not shown.
Binary file modified packages/build/tests/core/lifecycle/snapshots/tests.js.snap
Binary file not shown.
Binary file modified packages/build/tests/plugins/api/snapshots/tests.js.snap
Binary file not shown.
Binary file modified packages/build/tests/plugins/config/snapshots/tests.js.snap
Binary file not shown.
Binary file modified packages/build/tests/plugins/constants/snapshots/tests.js.snap
Binary file not shown.
Binary file modified packages/build/tests/plugins/duplicate/snapshots/tests.js.snap
Binary file not shown.
Binary file modified packages/build/tests/plugins/env/snapshots/tests.js.snap
Binary file not shown.
Binary file modified packages/build/tests/plugins/functions/snapshots/tests.js.snap
Binary file not shown.
Binary file modified packages/build/tests/plugins/install/snapshots/tests.js.snap
Binary file not shown.
34 changes: 0 additions & 34 deletions packages/build/tests/plugins/load/snapshots/tests.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,40 +282,6 @@ Generated by [AVA](https://ava.li).
Have a nice day!␊
`

## Missing plugins

> Snapshot 1

`␊
> Starting Netlify Build v1.0.0␊
https://github.com/netlify/build␊
> Flags␊
{ config: '/file/path' }␊
> Current directory␊
/file/path␊
> Config file␊
/file/path␊
Error: 'does-not-exist' plugin not installed or found.␊
Please install it with npm or yarn.␊
Cannot find module 'does-not-exist' from '/file/path'␊
┌─────────────────────────────┐␊
│ Netlify Build Error │␊
└─────────────────────────────┘␊
Error: Command failed with exit code 1: npm install --no-progress --no-audit --no-fund does-not-exist␊
STACK TRACE␊
┌─────────────────────────────┐␊
│ END Netlify Build Error │␊
└─────────────────────────────┘␊
`

## Node module plugins

> Snapshot 1
Expand Down
Binary file modified packages/build/tests/plugins/load/snapshots/tests.js.snap
Binary file not shown.
Binary file modified packages/build/tests/plugins/validate/snapshots/tests.js.snap
Binary file not shown.
Binary file modified packages/build/tests/utils/cache/snapshots/tests.js.snap
Binary file not shown.
Binary file modified packages/build/tests/utils/git/snapshots/tests.js.snap
Binary file not shown.
Binary file modified packages/build/tests/utils/load/snapshots/tests.js.snap
Binary file not shown.
Binary file modified packages/build/tests/utils/run/snapshots/tests.js.snap
Binary file not shown.