question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

--dest doesn't work properly

See original GitHub issue

Do you want to request a feature or report a bug? Bug

What is the current behaviour? When I try to build for other destination using --dest, it throws an unrelated error which is only resolved I use --no-prerender along with it.

If the current behaviour is a bug, please provide the steps to reproduce.

preact build --dest ../public/build

What is the expected behaviour? The expected behaviour is that it should build, as it build with just preact build

If this is a feature request, what is motivation or use case for changing the behaviour?

Please mention other relevant information.

A sneakpeak of the Error

Error: Cannot find module 'preact'
Require stack:
- /Users/debdut/Code/Projects/blogletter/public/build/ssr-build/ssr-bundle.js
- /Users/debdut/Code/Projects/blogletter/blogletter.news/node_modules/preact-cli/lib/lib/webpack/prerender.js
- /Users/debdut/Code/Projects/blogletter/blogletter.news/node_modules/preact-cli/lib/lib/webpack/render-html-plugin.js
- /Users/debdut/Code/Projects/blogletter/blogletter.news/node_modules/preact-cli/lib/lib/webpack/webpack-client-config.js
- /Users/debdut/Code/Projects/blogletter/blogletter.news/node_modules/preact-cli/lib/lib/webpack/run-webpack.js
- /Users/debdut/Code/Projects/blogletter/blogletter.news/node_modules/preact-cli/lib/commands/build.js
- /Users/debdut/Code/Projects/blogletter/blogletter.news/node_modules/preact-cli/lib/commands/index.js
- /Users/debdut/Code/Projects/blogletter/blogletter.news/node_modules/preact-cli/lib/index.js
method: HteQ
at: /Users/debdut/Code/Projects/blogletter/blogletter.news/src/assets/images/browser-dark.png:1:41

This could be caused by using DOM or Web APIs.
Pre-render runs in node and has no access to globals available in browsers.

Consider wrapping code producing error in: 'if (typeof window !== "undefined") { ... }'

Alternatively use 'preact build --no-prerender' to disable prerendering.

This error seems irrelevant since I’m not using any Browser API such as window or document that will come in the way of prerender. Plus it builds perfectly if I don’t set the --dest

Please paste the results of preact info here.

Environment Info:
  System:
    OS: macOS 11.0
    CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
  Binaries:
    Node: 12.14.1 - ~/.nvm/versions/node/v12.14.1/bin/node
    Yarn: 1.22.5 - /usr/local/bin/yarn
    npm: 6.14.8 - ~/.nvm/versions/node/v12.14.1/bin/npm
  Browsers:
    Chrome: 83.0.4103.97
    Safari: 14.0.1
  npmPackages:
    preact: ^10.3.2 => 10.5.5 
    preact-cli: ^3.0.0 => 3.0.3 
    preact-render-to-string: ^5.1.4 => 5.1.10 
    preact-router: ^3.2.1 => 3.2.1 
  npmGlobalPackages:
    preact-cli: 3.0.3

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
rschristiancommented, Oct 21, 2020

Hm, might not be as simple as I assumed.

Seems to be that the issue is here, we ultimately can not require the ssr-bundle.js when that module’s own require statements cannot be resolved (as there is no preact package that can be resolved from ../public/build). I’ll play with this some more, but leaving a comment in case I need to leave this for a while.

0reactions
rschristiancommented, Dec 23, 2022

Going to close this out as a “won’t fix” as this is standard behavior in Node.

Read more comments on GitHub >

github_iconTop Results From Across the Web

gulp pipe(gulp.dest()) does not create any results
so i went to the root directory and searched all filesystem but there is no file named 'minjs' so i guess it just...
Read more >
12 reasons your standing desk is stuck & how to fix it
Keep reading to find out how to get your desk back in working condition. Standing desk won't go up - causes & solutions....
Read more >
Destination NAT Translation doesnt work properly with PA-5050
Hello Guys, Destination NAT translation doesn't work properly with PA-5050 ver 4.1.6 Scenario 1: - 1) Configured 213.42.55.x is mapped with - 3703....
Read more >
dest() - gulp.js
When directory is an empty string, throws an error with the message, "Invalid dest() folder argument. Please specify a non-empty string or a...
Read more >
Be Antibiotics Aware: Smart Use, Best Care | Patient Safety
Antibiotics DO NOT work on viruses, such as those that cause colds, flu, ... Ask your healthcare professional about the best way to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found