protobufjs / protobuf.js

Protocol Buffers for JavaScript & TypeScript.
Other
9.89k stars 1.42k forks source link

illegal token 'The' (awesome.proto, line 1) #914

Open iamthehunta opened 7 years ago

iamthehunta commented 7 years ago

protobuf.js version:

Trying to read a local .proto file in using your example documentation ``` awesome.proto is in my root directory protobuf.load("./awesome.proto", function(err, root) { if (err) throw err; }); ``` ``` Error: illegal token 'The' (awesome.proto, line 1) at illegal (parse.js:87) at parse (parse.js:715) at process (root.js:107) at root.js:182 at XMLHttpRequest.fetchOnReadyStateChange (index.js:103) at XMLHttpRequest.dispatchEvent (event-target.js:172) at XMLHttpRequest.setReadyState (XMLHttpRequest.js:538) at XMLHttpRequest.__didCompleteResponse (XMLHttpRequest.js:381) at XMLHttpRequest.js:485 at RCTDeviceEventEmitter.emit (EventEmitter.js:181) ```
dcodeIO commented 7 years ago

Looks like 'The' comes from an error page or something. You could try "/awesome.proto" without the leading dot when it's in the root directory.

iamthehunta commented 7 years ago

still getting the same error :/

dharmusharma1981 commented 7 years ago

Im also getting the same error

mctang719 commented 7 years ago

I am getting this error too. Anyone has the solution?

asciifaceman commented 7 years ago

It appears relative paths are either not working as described or broken in 6.8.0:

var builder = ProtoBuf.load("/Users/asciifaceman/development/project/file.proto");

Works, however

var builder = ProtoBuf.load("./file.proto"); var builder = ProtoBuf.load("/file.proto"); var builder = ProtoBuf.load("file.proto");

do not.

This might be a clarification issue on how relative paths work (if they do at all anymore).

shiyunsheng commented 6 years ago

please tell me , How to solve it

aybb commented 6 years ago

Ok, so absolute path works but its worthless on mobile app. I was lucky enough that my web developer provided me link to the same file on web site. So https link inside worked, but i doubt that this is the best idea ever

BigEgret commented 6 years ago

Hello, have you solved this problem? @iamthehunta @mctang719 @dharmusharma1981 我是在vue.js里面使用的 protobuf.load Uncaught Error: illegal token '<' (awesome.proto, line 1)

dcodeIO commented 6 years ago

If you are seeing an illegal token 'The' or illegal token '<' kind of error, that's due to the server responding with a 404ish error page when requesting the proto file, i.e. the file does not exist where protobuf.js looked for it. Can't parse an HTML document. Didn't check what's going on this relevative paths, though.

BigEgret commented 6 years ago

@dcodeIO Is there any solution to this problem?

dcodeIO commented 6 years ago

Make sure that the file the library requests is present on the server. You can check that by looking at your browser developer console's network log.

BigEgret commented 6 years ago

I looked at the browser that loaded the awesome. proto file on the server!

shadowfax-h commented 5 years ago

.proto must be accessed through your server!