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

Error setting Cloud Code file: On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:' #8815

Closed
rjcodedev opened this issue Nov 18, 2023 · 9 comments
Labels
type:question Support or code-level question

Comments

@rjcodedev
Copy link

New Issue Checklist

Issue Description

this issue occur when I pass __dirname + '/cloud/main.js' cloud params in new ParseServer instance in my windows laptop

Steps to reproduce

clone parse-server-example and run it in windows laptop
or you can create your own parse-server setup and run it

Server

  • Parse Server version: 6.3.1
  • Operating system: windows 11
  • Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc): local

Database

  • System (MongoDB or Postgres): MongoDB
  • Database version: 7.0
  • Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc): local

Client

  • SDK (iOS, Android, JavaScript, PHP, Unity, etc): javascript
  • SDK version: 4.1.0

Logs

Screenshot 2023-11-16 093734
Copy link

parse-github-assistant bot commented Nov 18, 2023

Thanks for opening this issue!

  • 🚀 You can help us to fix this issue faster by opening a pull request with a failing test. See our Contribution Guide for how to make a pull request, or read our New Contributor's Guide if this is your first time contributing.

@mtrezza mtrezza added type:bug Impaired feature or lacking behavior that is likely assumed state:duplicate Duplicate of already reported issue type:question Support or code-level question and removed type:bug Impaired feature or lacking behavior that is likely assumed state:duplicate Duplicate of already reported issue labels Nov 18, 2023
@rjcodedev
Copy link
Author

also forgot to mention that work perfectly fine in macos

@mtrezza
Copy link
Member

mtrezza commented Nov 18, 2023

Then this looks more like a URL issue than a Parse Server issue. Maybe post what the value is that you are setting for cloud.

@rjcodedev
Copy link
Author

rjcodedev commented Nov 18, 2023

import path from 'path';
const __dirname = path.resolve();

export const config = { databaseURI: 'mongodb://0.0.0.0:27017/dev', cloud: __dirname + "/cloud/main.js", appId: 'myAppId', masterKey: 'masterkey', //Add your master key here. Keep it secret! serverURL: 'http://localhost:1337/parse', // Don't forget to change to https if needed };

my current code looks like this

@mtrezza
Copy link
Member

mtrezza commented Nov 18, 2023

Add const cloudPath = __dirname + "/cloud/main.js"; and what is the value of cloudPath? And is main.js a ESM or CJS?

@rjcodedev
Copy link
Author

rjcodedev commented Nov 18, 2023

{"type":"module"}
code from main.js
await import('./functions.js');

output of this line of codeconst cloudPath = __dirname + "/cloud/main.js"; is C:\mycompany\parse-server-example/cloud/main.js

@rjcodedev
Copy link
Author

I also tried this path './cloud/main.js' path still not working

@mtrezza
Copy link
Member

mtrezza commented Nov 18, 2023

The error explains the issue:

On Windows, absolute paths must be valid file URLs.

Your path is C:\mycompany\parse-server-example/cloud/main.js but it should start with file:// protocol.

I'm closing this as it does not seem to be a Parse Server issue.

@mtrezza mtrezza closed this as completed Nov 18, 2023
@mtrezza mtrezza changed the title An error with npm start: Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file and data are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:' On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:' Nov 18, 2023
@mtrezza mtrezza changed the title On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:' Error importing Cloud JS file: On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:' Nov 18, 2023
@mtrezza mtrezza changed the title Error importing Cloud JS file: On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:' Error setting Cloud Code file: On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:' Nov 18, 2023
@rjcodedev
Copy link
Author

rjcodedev commented Nov 18, 2023

I have tried this file://C:/mycompany/parse-server-example/cloud/main.js but not working
@mtrezza

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:question Support or code-level question
Projects
None yet
Development

No branches or pull requests

2 participants