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

SyntaxError: Unexpected token = #50

Closed
xman51 opened this issue Sep 20, 2017 · 7 comments
Closed

SyntaxError: Unexpected token = #50

xman51 opened this issue Sep 20, 2017 · 7 comments

Comments

@xman51
Copy link

xman51 commented Sep 20, 2017

I am unable to run my application with express-fileupload installed. I get the following error when attempting to run my application:

/node_modules/express-fileupload/lib/index.js:137
mv: function(path, callback = null) {
^

SyntaxError: Unexpected token =
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object. (/.js:10:16)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)

Here is my route code:

app.post("/admin/hoverimage/upload/:id", function(req, res){
			if (!req.files)
    	return res.status(400).send("No files were uploaded.");
			console.log(req.body);
			// The name of the input field (i.e. "sampleFile") is used to retrieve the uploaded file
  		let hoverimage = req.files.hoverimage;
			let path = "/media/"+hoverimage.name;
			hoverimage.mv(path, function(err) {
				if (err)
					return res.status(500).send(err);
				res.send("File uploaded!");
			});
			//res.redirect("/admin/gallery/images/"+id);
		});

Please advise.

@rrufus
Copy link

rrufus commented Oct 1, 2017

I am also seeing this issue

@zarcha
Copy link

zarcha commented Oct 4, 2017

you can remove the " = null" on line 137 and it fixes that issue

@richardgirges
Copy link
Owner

Hey thanks for the report. Can I get some more detail about your environment? Such as the version of node that you're using. I will try to reproduce and fix this issue asap.

@zarcha
Copy link

zarcha commented Oct 5, 2017

Sorry I spoke a little too soon on versions. My development environment has node v6.11.3 and and the other production environment that is failing uses v4.7.2

Both have the exact same code. I get the above error at line 137. Removing what i said fixes the issue and has caused no noticeable issues on either version.

@r3wt
Copy link
Contributor

r3wt commented Oct 5, 2017

@richardgirges on the one hand i don't think we should fix it. but on the other hand, we won't be able to provide fixes to people who are using old versions of node.

solution:

  1. fix in current major version and bump package minor version. leave this as the main fork
  2. new branch and bump major package version with restrictions on engine support, taking advantage of all the nice things es5/es6 offers us. this way we can take advantage of modern features without bc break in current version.

@zarcha
Copy link

zarcha commented Oct 5, 2017

Thats also fine @r3wt . Its also an issue with v5.8.0 which my macbook uses. The v4.7.2 is what ubuntu provides in its repo for using apt-get so i would think people using linux will run into this issue. Its not an issue for me now since i fixed it in my code base.

@richardgirges
Copy link
Owner

Ya @r3wt I agree that we should uphold support for 6 and above.

Because this is such a trivial fix, I'm going to go ahead and push it up and cut a minor version like you suggested, followed by another minor version update with the restrictions on engine support.

This was referenced Nov 18, 2019
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

No branches or pull requests

5 participants