-
Notifications
You must be signed in to change notification settings - Fork 916
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cleanup unresolved error messages (#473)
- Loading branch information
1 parent
18a213b
commit 5adee6d
Showing
7 changed files
with
75 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
## Troubleshooting | ||
|
||
### Node built-in could not be resolved | ||
|
||
``` | ||
✖ /my-application/node_modules/dep/index.js | ||
"http" (Node.js built-in) could not be resolved. | ||
``` | ||
|
||
Some packages are written with dependencies on Node.js built-in modules. This is a problem on the web, since Node.js built-in modules don't exist in the browser. For example, `import 'path'` will run just fine in Node.js but would fail in the browser. | ||
|
||
To solve this issue, you can either replace the offending package ([pika.dev](https://pika.dev/) is a great resource for web-friendly packages) or add Node.js polyfill support: | ||
|
||
```js | ||
// snowpack.config.js | ||
// Plugin: https://github.com/ionic-team/rollup-plugin-node-polyfills | ||
module.exports = { | ||
installOptions: { | ||
rollup: { | ||
plugins: [require("rollup-plugin-node-polyfills")()] | ||
} | ||
} | ||
}; | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
test/integration/error-node-builtin-unresolved/expected-output.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
- snowpack installing... | ||
⠼ snowpack installing... mock-test-package | ||
✖ node_modules/mock-test-package/entrypoint.js | ||
"http" (Node.js built-in) could not be resolved. (https://www.snowpack.dev/#node-built-in-could-not-be-resolved) | ||
✔ snowpack install complete with errors. | ||
|
||
⦿ web_modules/ size gzip brotli | ||
└─ mock-test-package.js XXXX KB XXXX KB XXXX KB |
3 changes: 3 additions & 0 deletions
3
test/integration/error-node-builtin-unresolved/node_modules/mock-test-package/entrypoint.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
test/integration/error-node-builtin-unresolved/node_modules/mock-test-package/package.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
test/integration/error-node-builtin-unresolved/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"scripts": { | ||
"TEST": "node ../../../pkg/dist-node/index.bin.js" | ||
}, | ||
"dependencies": { | ||
"mock-test-package": "^1.2.3" | ||
}, | ||
"snowpack": { | ||
"install": ["mock-test-package"] | ||
} | ||
} |