Skip to content
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

throw Error: ENOENT: no such file or directory, stat '...' when using Vite #38

Closed
johnsoncodehk opened this issue Nov 26, 2020 · 7 comments · Fixed by #40
Closed

throw Error: ENOENT: no such file or directory, stat '...' when using Vite #38

johnsoncodehk opened this issue Nov 26, 2020 · 7 comments · Fixed by #40

Comments

@johnsoncodehk
Copy link

First thanks for your great work, it is very easy to use!

My only problem is when I start a Vite server, there will throw many Error: ENOENT: no such file or directory, stat '...' errors.

I found the reason is because the npm publish has include .map files and the mapping .ts files do not include.

I see you have add .js.map to .gitignore now, but not enough. if "sourceMap": true is set, there will add a line like //# sourceMappingURL=assert.js.map to .js files, so there still has .map files not found errors, you must to disable sourceMap option for publish.

@timostamm
Copy link
Owner

Thanks for the feedback, @johnsoncodehk

I did a npm install @protobuf-ts/runtime in a fresh new project and had a look at the contents of node_modules/@protobuf-ts/runtime/.

Bildschirmfoto 2020-11-26 um 11 15 31

(I removed all source files except "assert") just to make it a bit easier.

Looking at build/commonjs/assert.js:

// code omitted
//# sourceMappingURL=assert.js.map

build/es2015/assert.js:

// code omitted
//# sourceMappingURL=assert.js.map

build/types/assert.d.ts:

// declarations omitted
//# sourceMappingURL=assert.d.ts.map

All files referenced by sourceMappingURL exist. The mapping files look very similar. This is build/commonjs/assert.js.map:

{"version":3,"file":"assert.js","sourceRoot":"","sources":["../../src/assert.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,SAAgB,MAAM,CAAC,SAAc,EAAE,GAAY;IAC/C,IAAI,CAAC,SAAS,EAAE;QACZ,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;KACxB;AACL,CAAC;AAJD,wBAIC;AAED;;GAEG;AACH,SAAgB,WAAW,CAAC,KAAY,EAAE,GAAY;IAClD,MAAM,IAAI,KAAK,CAAC,GAAG,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CAOC"}

So the problem seems to be ../../src/assert.ts. This path simply does not exists in the published package...

Could you verify if your error goes away if you add the .ts source files?
You can download them from here: https://github.com/timostamm/protobuf-ts/tree/v1.x/packages/runtime/src (note the v1.x branch)
Then place the ts files in your node_modules/@protobuf-ts/runtime/src/ directory.

If this fixes your error, I will add the files to the published packages.

@johnsoncodehk
Copy link
Author

Yes current release version have .map files, but I see you have added .js.map in .gitignore:

/build/**/*.js.map

so I guess .map will remove in next version, maybe I'm wrong.

I already remove .map and //# sourceMappingURL= in my local node_modules to remove errors, so you don't need to publish version for me now :).

Yes if you add .ts files to npm release can resolve this problem, but I think disable sourceMap for publish build is better, hope it can fix in next version.

And thanks you work again!

@timostamm
Copy link
Owner

I see you have added .js.map in .gitignore

Yes, but there also is a .npmignore. This means .gitignore does not matter for npm publish.

I think disable sourceMap for publish build is better

Seems like there is no definite answer, see googleapis/google-cloud-node#2867 for example.

But I think I prefer removing source maps instead of adding typescript sources. I'll give it some more thought. Let's keep this issue open as a reminder.

@johnsoncodehk
Copy link
Author

Yes I think removing source maps is better too! (may be some misunderstanding before)

@timostamm
Copy link
Owner

@johnsoncodehk, source mappings have been removed in prerelease version v2.0.0-alpha.2.

If this does not fix the issue, please reopen.

@timostamm
Copy link
Owner

The fix has been back-ported in v1.0.12

@johnsoncodehk
Copy link
Author

I already using 2.x, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants