sapper icon indicating copy to clipboard operation
sapper copied to clipboard

can't run basic example

Open zw5 opened this issue 5 years ago • 29 comments

PS C:\Users\ximon\documents> npx degit "sveltejs/sapper-template#rollup" tech
npx: installed 1 in 2.752s
> cloned sveltejs/sapper-template#rollup to tech
PS C:\Users\ximon\documents> cd tech
PS C:\Users\ximon\documents\tech> npm install
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules\rollup\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN [email protected] No repository field.
npm WARN [email protected] No license field.

added 262 packages from 182 contributors and audited 264 packages in 40.253s

17 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

PS C:\Users\ximon\documents\tech> npm run dev

> [email protected] dev C:\Users\ximon\documents\tech
> sapper dev

Entry module "rollup.config.js" is implicitly using "default" export mode, which means for CommonJS output that its default export is assigned to "module.exports". For many tools, such CommonJS output will not be interchangeable with the original ES module. If this is intended, explicitly set "output.exports" to either "auto" or "default", otherwise you might want to consider changing the signature of "rollup.config.js" to use named exports only.
✗ client
Could not resolve entry module (undefined\client.js).
✗ server
Could not resolve entry module (undefined\server.js).
internal/modules/cjs/loader.js:1032
  throw err;
  ^

Error: Cannot find module 'C:\Users\ximon\documents\tech\__sapper__\dev\server\server.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1029:15)
    at Function.Module._load (internal/modules/cjs/loader.js:898:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}
> Server crashed
✗ service worker
Could not resolve entry module (undefined\service-worker.js).

zw5 avatar Jul 23 '20 01:07 zw5

Possibly a duplicate of https://github.com/sveltejs/sapper/issues/1333

Can you share what version of Node.js you have installed?

benmccann avatar Jul 23 '20 02:07 benmccann

I'm on node 14.4.0

zw5 avatar Jul 23 '20 15:07 zw5

And for some reason the web server works as expected when I use Visual Studio Code's built-in debugger.

zw5 avatar Jul 23 '20 15:07 zw5

@zw5 can you try this on node v12 please and see if you have a better result?

antony avatar Aug 07 '20 08:08 antony

I am on node v14.2.0 and it works fine

TheComputerM avatar Aug 10 '20 08:08 TheComputerM

@antony I have tried without success.

zw5 avatar Aug 11 '20 16:08 zw5

PS C:\Users\ximon\documents> npx degit "sveltejs/sapper-template#rollup" tech
npx: installed 1 in 25.293s
> cloned sveltejs/sapper-template#rollup to tech
PS C:\Users\ximon\documents> cd tech
PS C:\Users\ximon\documents\tech> npm install
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules\rollup\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN [email protected] No repository field.
npm WARN [email protected] No license field.


17 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

PS C:\Users\ximon\documents\tech> npm run dev

> [email protected] dev C:\Users\ximon\documents\tech
> sapper dev

✗ client
(node:14024) UnhandledPromiseRejectionWarning: Error: Could not find chunk that owns index.svelte
    at C:\Users\ximon\Documents\tech\node_modules\sapper\dist\create_manifest_data.js:570:10
    at Array.forEach (<anonymous>)
    at extract_css (C:\Users\ximon\Documents\tech\node_modules\sapper\dist\create_manifest_data.js:564:13)
    at RollupResult.to_json (C:\Users\ximon\Documents\tech\node_modules\sapper\dist\create_manifest_data.js:752:9)
    at handle_result (C:\Users\ximon\Documents\tech\node_modules\sapper\dist\dev.js:335:28)
    at C:\Users\ximon\Documents\tech\node_modules\sapper\dist\dev.js:429:5
    at WatchEmitter.<anonymous> (C:\Users\ximon\Documents\tech\node_modules\sapper\dist\create_manifest_data.js:884:6)
    at WatchEmitter.emit (events.js:314:20)
    at Watcher.emit (C:\Users\ximon\documents\tech\node_modules\rollup\dist\shared\watch.js:611:22)
    at Watcher.run (C:\Users\ximon\documents\tech\node_modules\rollup\dist\shared\watch.js:649:18)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:14024) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:14024) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Could not resolve entry module (undefined\server.js).
Terminate batch job (Y/N)? N

zw5 avatar Aug 11 '20 16:08 zw5

Are you using Sapper 0.28.0? It had some fixes in this section of the code for Windows: https://github.com/sveltejs/sapper/blob/master/CHANGELOG.md#0280

benmccann avatar Aug 11 '20 16:08 benmccann

I am also now having this issue after upgrading to 0.28.3 from 0.28.2, I am on nodejs 14.9.0

image

maddalax avatar Sep 03 '20 15:09 maddalax

Confirming that I'm seeing this problem on 0.28.3 on Win10 running Node 14.0.6, and dropping down to 0.28.2 didn't help, nor did swapping out Node 14.0.6 for 12.18.4 or 14.13.0. EDIT: Also tried 0.28.10 (all installed from npm, not directly from the github repository)

However, 0.28.3 running Node v12.18.(3|4) on Debian 9.13 works fine, as did Node v14.13.0 on Debian 10.6. Tomorrow, during/after maintenance, I'll check Node v14.13.0 on Debian 9.13, though I don't expect that to be any different.

As near as I can tell, this seems to come down to "broken on Win10" though I'll readily admit that I haven't done enough testing to conclusively state that. Every message I see on this issue that shows paths shows Windows-style paths and I don't see any messages saying that it works where the OS is mentioned.

EricGeek avatar Oct 05 '20 01:10 EricGeek

Can you try with 0.28.10 instead since that's the latest?

benmccann avatar Oct 05 '20 02:10 benmccann

done. In fact, I think I misread something and my 0.28.3 tests were actually running 0.28.10.

Also, to be specific, I'm getting the errors that zw5 reported the first time, could not resolve entry module:

`PS C:\Users\Eric\devel\sapper-learning2> npm run dev

[email protected] dev C:\Users\Eric\devel\sapper-learning2 sapper dev

✗ client Could not resolve entry module (undefined\client.js). ✗ server Could not resolve entry module (undefined\server.js). internal/modules/cjs/loader.js:905 throw err; ^

Error: Cannot find module 'C:\Users\Eric\devel\sapper-learning2_sapper_\dev\server\server.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15) at Function.Module._load (internal/modules/cjs/loader.js:747: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: [] }

Server crashed ✗ service worker Could not resolve entry module (undefined\service-worker.js).`

EDIT: insert code didn't work well, what works better? it turned (with spaces added) \ _ _ sapper _ _ into _ sapper _

EDIT2: I played around with versions of sapper that predate the reporting of this problem (0.27.13 and 0.26.1) and the problem still exists, so the problem may not be in sapper itself.

EricGeek avatar Oct 05 '20 02:10 EricGeek

I can't reproduce this, so someone from the community will have to debug. A couple of things I would suggest:

  • try on versions of Sapper in between (remove the ^ from the version in package.json, specify the version to test, and run npm install again) in order to narrow down the exact version this began happening
  • put a console.log statement to print src on the lines below. npm link Sapper into your project and then run npm run build to build Sapper

https://github.com/sveltejs/sapper/blob/bf47169dbe4decc236f5c89b042bf8cb8201d002/src/api/dev.ts#L217 https://github.com/sveltejs/sapper/blob/bf47169dbe4decc236f5c89b042bf8cb8201d002/src/config/rollup.ts#L11

benmccann avatar Oct 06 '20 15:10 benmccann

@EricGeek console.log the result of the sapper.config.client() or whatever the line is that is the input to your client and server bundle.

I had the same issue once but it was because I was doing something weird with the sapper module and my input to each of the rollup bundles was therefore undefined.

antony avatar Oct 06 '20 16:10 antony

Just so that no one thinks I up and disappeared as soon as work was asked, here's what I've got so far.

As mentioned in the edit above, I tried older versions of sapper (0.27.13, which came out before this issue was first entered, and 0.26.1, which should seriously predate the issue) and had the same results, so I think the issue is in a dependency, not in sapper itself, unless this issue is seriously old.

As for tracing the issue with console logs, I've found that env.set_src is getting called with the correct information, but in rollup.js, after env is required, a console.log shows that only the three set_ functions exist on the env object, none of the variables are present, so the function that gets assigned to input is returning undefined/client.js.

I rewrote build/env.js to use getters and setters of local variables, and that didn't change anything. So then I created a local variable 'foo' that didn't get exported and set it to 1, then console logged ++foo every time I was in the getter or setter. And as you might expect, I logged "++foo=2" twice, so it appears I've got multiple instances of the env module under windows somehow. I get higher numbers for ++foo after those from later gets I added for debugging. Hmmm.... there's some kind of hot module reloading going on when running "npm run dev", isn't there? Any way to disable that?

Just to test, I hardcoded the values and "npm run dev" works, though I'm getting nothing from the server, so whatever the problem is, this may not be the only place the problem occurs. Time to add some console logging to server.js to see what it's doing. Oops, while I was writing this up, it suddenly started working, so maybe there's some kind of startup issue, because forced full refreshes return right away now.

Hmmm... "npm run build" claims to work, but it doesn't build the server. Not surprising given the hack to get around the first problem. More experimenting to do.

Sorry this is progressing so slowly, work blew up and this is the first chance I've had to get back to this, and last time I had the opportunity to work with JavaScript to any degree, jQuery wasn't even a thing yet, so I'm doing a whole lot of catching up (modules, rollup, npm, etc) all at the same time.

EricGeek avatar Oct 08 '20 07:10 EricGeek

Nope, changing the dev script to "dev": "sapper dev --no-hot" didn't fix it. And excuse me while I go shame myself for asking a question with an answer that was literally one google query away.

EricGeek avatar Oct 08 '20 07:10 EricGeek

Got a lead from an unusual place, Maximilian Schwarzmüller's svelte/sapper module on Udemy has a starter that looks like it's derived from an earlier version of the rollup version of this template that works. I updated it to run the latest version of sapper (it was already loading the latest version of svelte), and it worked fine. Looking it over, most of the differences between the two come from the version of rollup used. The Udemy version is using rollup 1.32.1, the official template is installing 2.28.2.

So the next step for me is to change the Udemy template so that rollup is the only difference, and if it still works, tryupgrading the version of rollup. Rollup is a black box to me at this time, but I'm going to dive in and see what I can find.

EricGeek avatar Oct 10 '20 02:10 EricGeek

Here is some info I could provide at least:

OS: Windows 10 version 1903 Node version: 12.18.0 Npm version: 6.14.4

Tried different versions of Sapper to see when this occur. Tries were made with setting specific version of Sapper in the package.json file.

This is with Sapper version: 0.28.2 and above PS F:\code\x> npm run dev

[email protected] dev F:\code\x sapper dev

✗ server Could not resolve entry module (undefined\server.js). ✗ client Could not resolve entry module (undefined\client.js). internal/modules/cjs/loader.js:969 throw err; ^

Error: Cannot find module 'F:\code\x_sapper_\dev\server\server.js' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15) at Function.Module._load (internal/modules/cjs/loader.js:842:27) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) at internal/main/run_main_module.js:17:47 { code: 'MODULE_NOT_FOUND', requireStack: [] }

Server crashed ✗ service worker Could not resolve entry module (undefined\service-worker.js).

This is with Sapper version: 0.28.0 and 0.28.1 PS F:\code\x> npm run dev

[email protected] dev F:\code\x sapper dev

✗ client Could not resolve entry module (undefined\client.js). ✗ server Could not resolve entry module (undefined\server.js). (node:10360) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, scandir 'F:\code\x_sapper_\dev\server' at Object.readdirSync (fs.js:948:3) at Object.inject_resources (F:\Code\x\node_modules\sapper\dist\copy_runtime.js:30:8) at F:\Code\x\node_modules\sapper\dist\dev.js:359:17 at WatchEmitter. (F:\Code\x\node_modules\sapper\dist\create_manifest_data.js:801:37) at WatchEmitter.emit (events.js:315:20) at Watcher.emit (F:\code\x\node_modules\rollup\dist\shared\watch.js:612:22) at Watcher.run (F:\code\x\node_modules\rollup\dist\shared\watch.js:650:18) (node:10360) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:10360) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. ✗ service worker Could not resolve entry module (undefined\service-worker.js).

Im running the same project x on my work laptop which is working with spec: OS: Windows 10 version 1903 Node version: 12.14.1 Npm version: 6.13.4

The difference I can see is lower node and npm version but also where the project is located on which drive. On my desktop pc is located under "F:" but work laptop is located under "C:". Don't know if that make any sense.

Update: Ran 'npx degit "sveltejs/sapper-template#rollup"' my-app on my desktop pc where I have the problem with my own project. This did run successful with "npm run dev". Then I ran "npm run dev" on my "'F:\code\x" project and it did work now as well. I'm not an node/npm expert so I can't point out why it did work now by just getting a fresh Rollup template locally and install the dependencies for that project and then just run "npm run dev" on my project that was not working before.

gran0123 avatar Oct 11 '20 11:10 gran0123

It's working for me too now, but my story is even stranger. I was going to try converting the udemy template I previously mentioned over to rollup 2.X to see if/how it broke, so I downloaded a fresh rollup template, did the npm install and npm run dev, and it just worked. I don't see any recent commits to sapper that don't involve typescript support, so I'm not sure what happened.

It gets weirder. I took one of my "broken" installs (after testing it to make sure it was still broken), nuked node_modules, "npm install" and then "npm run dev" all without updating the template, and it came up. Weirder still, "npm ls" output was identical before and after the nuke/reinstall. I can't explain this, but I'm happy it's working. On the other hand, I hate problems that just go away without me understanding them.

EricGeek avatar Oct 13 '20 21:10 EricGeek

Update on this from my latest post: Seems to be something with windows terminal that is spooky. Installing a template from cmd prompt is working excellent but with windows terminal running powershell this problem seems to occur, for me at least.

gran0123 avatar Oct 19 '20 16:10 gran0123

I have been lurking on this issue for the most part, mostly because I am not experienced at all with node.js, but now that you mention terminals, I realize, "Hey that's something I can test!", so I went in and ran it in two different command prompts. When I run it on cmd:

C:\tech>npm run dev

> [email protected] dev C:\tech
> sapper dev

✔ client (3.4s)
✔ server (3.5s)
✔ service worker (85ms)
> Listening on http://localhost:3000

when I run it on powershell

> sapper dev

✗ server
Could not resolve entry module (undefined\server.js).
✗ client
Could not resolve entry module (undefined\client.js).
✗ service worker
Could not resolve entry module (undefined\service-worker.js).
internal/modules/cjs/loader.js:1068
  throw err;
  ^

Error: Cannot find module 'C:\tech\__sapper__\dev\server\server.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1065:15)
    at Function.Module._load (internal/modules/cjs/loader.js:911:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
    at internal/main/run_main_module.js:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}
> Server crashed

zw5 avatar Oct 23 '20 13:10 zw5

I have a project in the \Sapper\practice folder if you write the final folder in Terminal with a capital letter, for example Practice - there will be a mistake

solved the problem like this:
cd ..
cd practice (lowercase)

lilser2 avatar Nov 11 '20 14:11 lilser2

Huh, that's weird because my path is all lowercase.

zw5 avatar Nov 19 '20 18:11 zw5

I got the same error too using window powershell. But no error with git bash. This is really weird.

padunk avatar Dec 07 '20 23:12 padunk

Same here. Testing different shells with the same project. node v14.15.0. works in cygwin bash and from within VS Code Terminal but not from a command prompt. There the errors are a bit different from the above, though:

c:\Data\Development\Svelte\sapper$ npm run dev

[email protected] dev c:\Data\Development\Svelte\sapper sapper dev

✗ server Unexpected character '�' (Note that you need plugins to import files that are not JavaScript) f 2 t i� � � 7 7 GIMP 2.10.14 2020:02:08 18:32:30 � � ���� JFIF �� C ^ 2!!22222222222222222222222222222222222222222222222222�� � " �� 3: �� � } !1AQa"q2��#B��R��$3br� ✗ client Unexpected character '�' (Note that you need plugins to import files that are not JavaScript) f 2 t i� � � 7 7 GIMP 2.10.14 2020:02:08 18:32:30 � � ���� JFIF �� C ^ 2!!22222222222222222222222222222222222222222222222222�� � " �� 3: �� � } !1AQa"q2��#B��R��$3br� internal/modules/cjs/loader.js:883 throw err; ^

Error: Cannot find module 'c:\Data\Development\Svelte\sapper_sapper_\dev\server\server.js' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15) at Function.Module._load (internal/modules/cjs/loader.js:725: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: [] }

Server crashed ✔ service worker (43ms)

arminus avatar Dec 18 '20 08:12 arminus

Same problem as arminus here Windows 10 node v12.13.0 npm v6.13.0

Stefdv avatar Dec 22 '20 12:12 Stefdv

I got the same error too using window powershell. But no error with git bash. This is really weird.

I cannot believe this worked.

PowerShell wasn't working. Git Bash actually worked for me.

Windows 10 node v13.7.0 npm v6.13.6

sapper 0.28.0 and sapper 0.28.10

AnyhowStep avatar Jan 21 '21 17:01 AnyhowStep

Problem occurs for me only when run form terminal inside vscode. ~~Running from an instance git bash inside vscode breaks, but the same terminal outside (standalone) does not.~~ I think this is only true because it's not instantiated in the target directory in the same way vscode is.

Win 10 19041 Vscode 1.52.1 Node v12.14.1

To "solve" this problem inside vscode terminal ( cmd/bash...whatever);

  1. current path c:/a/b/c/project
  2. navigate from that path to c:
  3. navigate back in to the project path > c:/a/b/c/project
  4. the context should now be set and the project should run.. why idk.

Maybe this can help resolve why it happens somehow.

GIT BASH In vscode :

asd@HMM MINGW64 /c/a/b/repo (branchy)
$ npm run dev

> [email protected] dev C:\a\b\repo 
> sapper dev

✗ server
Could not resolve entry module (undefined\server.js).
✗ client
Could not resolve entry module (undefined\client.js).
(node:19136) UnhandledPromiseRejectionWarning: Error: Could not find chunk that owns index.svelte
    at C:\a\b\repo\node_modules\sapper\dist\create_manifest_data.js:570:10    at Array.forEach (<anonymous>)
    at extract_css (C:\a\b\repo\node_modules\sapper\dist\create_manifest_data.js:564:13)
    at RollupResult.to_json (C:\a\b\repo\node_modules\sapper\dist\create_manifest_data.js:752:9)
    at handle_result (C:\a\b\repo\node_modules\sapper\dist\dev.js:335:28) 
    at C:\a\b\repo\node_modules\sapper\dist\dev.js:429:5
    at WatchEmitter.<anonymous> (C:\a\b\repo\node_modules\sapper\dist\create_manifest_data.js:884:6)
    at WatchEmitter.emit (events.js:223:5)
    at Watcher.emit (C:\a\b\repo\node_modules\rollup\dist\shared\watch.js:611:22)
    at Watcher.run (C:\a\b\repo\node_modules\rollup\dist\shared\watch.js:649:18)
(node:19136) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 
1)
(node:19136) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

The type of terminal does not seem to matter. Where and how it's instantiated seems to be much more important.


After some renaming of the full path c:/A/b/c/D to c:/a/b/c/d I am unable to reproduce the issue.

mallsoft avatar Jan 25 '21 08:01 mallsoft

Hey guys. Running powershell as an admin and running "npm run dev" worked for me. I presume its a permissions issue in Windows 10 when Sapper needs to rebuild some dependencies (change the disk).

tsgenge avatar Jun 03 '21 07:06 tsgenge