jashkenas/coffeescript

Error while installing Coffee-script@1.12.8 'invalid or unexpected token'

Closed this issue Β· 65 comments

eashi commented

When I try to install like below I get the error.
I am using NPM 5.6.0 on a Windows 10 Machine .

npm install -g coffee-script@1.12.8
C:\Users\myuser\AppData\Roaming\npm\cake -> C:\Users\myuser\AppData\Roaming\npm\node_modules\coffee-script\bin\cake
C:\Users\myuser\AppData\Roaming\npm\coffee -> C:\Users\myuser\AppData\Roaming\npm\node_modules\coffee-script\bin\coffee

coffee-script@1.12.8 postinstall C:\Users\myuser\AppData\Roaming\npm\node_modules\coffee-script
node --eval 'if (require("./package.json").name === "coffee-script") { var red, yellow, cyan, reset; red = yellow = cyan = reset = ""; if (!process.env.NODE_DISABLE_COLORS) { red = "\x1b[31m"; yellow = "\x1b[33m"; cyan = "\x1b[36m"; reset = "\x1b[0m"; } console.warn(red + "CoffeeScript has moved!" + reset + " Please update references to " + yellow + ""coffee-script"" + reset + " to use " + yellow + ""coffeescript"" + reset + " (no hyphen) instead."); console.warn("Also, a new major version has been released under the " + yellow + "coffeescript" + reset + " name on NPM. This new release targets modern JavaScript, with minimal breaking changes. Learn more at " + cyan + "http://coffeescript.org" + reset + "."); console.warn(""); }'

'if
^^^
SyntaxError: Invalid or unexpected token
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Object. (eval-wrapper:6:22)
at Module._compile (module.js:570:32)
at evalScript (bootstrap_node.js:354:27)
at run (bootstrap_node.js:123:11)
at run (bootstrap_node.js:390:7)
at startup (bootstrap_node.js:122:9)
at bootstrap_node.js:505:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! coffee-script@1.12.8 postinstall: node --eval 'if (require("./package.json").name === "coffee-script") { var red, yellow, cyan, reset; red = yellow = cyan = reset = ""; if (!process.env.NODE_DISABLE_COLORS) { red = "\x1b[31m"; yellow = "\x1b[33m"; cyan = "\x1b[36m"; reset = "\x1b[0m"; } console.warn(red + "CoffeeScript has moved!" + reset + " Please update references to " + yellow + "\"coffee-script\"" + reset + " to use " + yellow + "\"coffeescript\"" + reset + " (no hyphen) instead."); console.warn("Also, a new major version has been released under the " + yellow + "coffeescript" + reset + " name on NPM. This new release targets modern JavaScript, with minimal breaking changes. Learn more at " + cyan + "http://coffeescript.org" + reset + "."); console.warn(""); }'
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the coffee-script@1.12.8 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\myuser\AppData\Roaming\npm-cache_logs\2017-11-30T08_12_56_775Z-debug.log

Experiencing the same thing with npm 3.10.10 on win 10

Seeing the same with npm 5.3.0

To be clear, if you are able to change your dep, you should use coffeescript instead of coffee-script. The issue remains for nested deps.

Same issue is there for Windows 10 and npm 5.5.1

Same issue here Windows 8.1 & npm 3.5.2. Karma is loading the coffeescript package.

4O4 commented

I don't want to hurry you, but is there any ETA? This is a critical issue for most of us :)

Why did not you use "deprecated" field from package.json?
We are waiting for your fix, since we have dropped the production release now. We use a third-party library that uses your library.

As a quick workaround, you can reference an older version of the library in your package.json.
"coffee-script": "1.12.7" worked in my case.

4O4 commented

My package.json looks funny now with typescript and coffeescript side by side πŸ˜„ But it works, thanks @garvik

image

pmaza commented

The problem is that many third-party libraries use this library.

+1 @pmaza. I'm new to node, is there a way to enforce the use of a version for a package globally?

@garvik 's solution worked for me, even though I have only third party dependencies on this library.

I don't want to hurry you, but is there any ETA? This is a critical issue for most of us :)

I do not have npm access. Paging @GeoffreyBooth.

pmaza commented

@meowthing I've just solved it right now installing "coffee-script@1.12.7" as a dev dependency.
Thanks @garvik!!

Adding "coffee-script": "1.12.7" as devDependency solved it. Thanks all!

I suppose that windows machine can't recognize the string argument wrapped in single quotes.
It should be wrapped in double quotes instead.

Would be great to unpublish the package or publish a fix. I think this is breaking many builds on Windows (it's breaking ours at least and we don't have a direct dependency on this package)

Same issue is there for Windows 7 and npm 6.11.0

I am having the same issue where coffee-script is an internal dependency of some third party module due to which actual installation of our npm module is failing.

I am using npm 5.4.2 on windows 7.

Please release the fix as soon as possible.

The same I installed 1.12.1 but vue-cli needs the newest and I can`t install it Windows 10 npm 5 node 8.9

There are always two ways out, go easy and go the right way. Simple - replace double quotes or replace the library (if possible). Is correct - to make fix as soon as possible

@GeoffreyBooth can you please communicate about an ETA ? Or unpublish the package ?

Yes this is just a mess, hard to fix in the dependency tree..

This is happening when you execute this command from the windows CMD, not from the mac or linux term, if you want to reproduce get a windows CMD and paste the node eval command that you execute on npm install

node --eval 'if (require("./package.json").name === "coffee-script") { var red, yellow, cyan, reset; red = yellow = cyan = reset = ""; if (!process.env.NODE_DISABLE_COLORS) { red = "\x1b[31m"; yellow = "\x1b[33m"; cyan = "\x1b[36m"; reset = "\x1b[0m"; } console.warn(red + "CoffeeScript has moved!" + reset + " Please update references to " + yellow + "\"coffee-script\"" + reset + " to use " + yellow + "\"coffeescript\"" + reset + " (no hyphen) instead."); console.warn("Also, a new major version has been released under the " + yellow + "coffeescript" + reset + " name on NPM. This new release targets modern JavaScript, with minimal breaking changes. Learn more at " + cyan + "http://coffeescript.org" + reset + "."); console.warn(""); }'

This will print the undesired
'if
^^^

Me too when trying to build in VSTS. It's a dependency on jasmine-node - I'm not using it directly.

I'm experiencing this on a mac too, doesn't seem to be a windows CMD specific issue. This was for a new installation of a package we use that depends on coffee-script

Tried @weihsth suggestion of adding coffee-script 1.12.7 to devDependencies, but no joy. 1.12.8 keeps being used.

Is there any ETA on a fix for this??

I've added "coffee-script": "1.12.7" to devDependencies to solve this issue (hopefully temporarily).

It is 4:30 am in LA right now. He probably committed this right before going to bed

Mac/Windows doesn't meter. But temporary solution with 1.12.8 works for me as well.

This guys phone is going to be throwing notifications like a crazy mo-fo when he wakes up.

It's the new LeftPad !

LOL Hope he sleeping well with Freddy Krueger!!

@admeister In my case, I had to add it to dependencies instead of devDependencies Β―\_(ツ)_/Β―

Solved! added this to package.json

  "devDependencies": {
    "coffee-script": "1.12.7"
  }

This should also fix it:

  "dependencies": {
    "coffee-script": "1.12.7"
  }

@xameeramir You have on p to many, if it's a direct copy/paste from your file, that might be the problem.
Otherwise, try adding it to dependencies, it worked in my case.

For mission critical production requirements, there is a work around - but it's not clean.

It involves using a local npm cache too which you publish a clone of v 1.12.7 'bumped' to 1.12.8 and then have your production environment utilise that as your source for packages

npm config edit
registry=http://feeds.acme.com/

Possible options for server is https://www.npmjs.com/package/sinopia

Would really appreciate a fast fix.

To clarify the severity of this issue: since this script breaks on Windows, it essentially breaks all packages that has coffee-script as a direct or nested dependency on Windows, including vue-cli. And since this is a nested dependency for us, we'd have to fork or ditch our direct dependency (which is hardly maintained anymore) if a prompt fix isn't possible.

@GMouron Added as direct dep

Kylir commented

Same issue. I'm using jasmine-node and it has coffee-script has a dependency.
Build broken on Windows 7 with Node 8.9.1.

Would really appreciate a fast fix.

People have posted workarounds here.
The people able to publish new versions are @jashkenas , @lydell , and @GeoffreyBooth . You'll need to wait for them to show up. There's not much else to do.

Posting "same issue" doesn't really help with anything. It's not technically difficult to solve.

@Kylir We have jasmine-node as a dependency and when I added "coffee-script" : "1.12.7" to our dependencies it picked up this version instead of the latest, which fixed it for us. Will remove it once the real issue is fixed.

@vendethiel there is no workaround for packages that has coffee-script as an indirect dependency, because we have no direct control over the version of coffee-script being used. The severity is being underestimated.

@yyx990803 I don't see how it is being underestimated. There just doesn't seem to be anyone awake with npm push rights. I'm open to suggestions.

@vendethiel no previous comments had pointed out the true implication of this bug (breaking all related packages on Windows), so it's worth pointing out. It's meaningful information and not "same issue here."

@yyx990803 correct me if I'm wrong, but any version of coffeescript you specify will get picked up, as long as it fits in version range specified by your third-party library.

@yyx990803 Comments from weihsth, vadimDidenko, pmaza, GMouron, BhupenderAgarwal24, ivanromakh, admeister already pointed that out. I think the point was well understood. It's critical. But there's nothing I/we can do right now.

When production environments are unable to build - it's beyond critical and the severity should not be underestimated.

Whilst the fix is simple - and there are work arrounds these aren't suitable for everyone and for them, the delay while we wait for a fix is a costly one.

@mbodecek good point! That is indeed a valid workaround before things gets fixed here (although not optimal as having to explicitly pin a non-direct dependency). Thanks.

@vendethiel even though a workaround is in place, it shows a significant failing in testing and deploying this commit to a package which is incredibly popular and used in lots of popular libraries. Might be worth investigating some more robust push policies/reviewing.

For yarn package manager need add "resolutions": { "coffee-script": "1.12.7" } to package.json

Has anyone contacted simon.lydell@gmail.com ? He is in Stockholm and should be awake

Same problem here when I tried to install i18n

Using old version of keystone which uses packages that are using coffee-script 1.12.8.
Fixed by adding coffee-script: 1.12.7 to my devDependencies.

Well, now that we have your attention πŸ˜„

I changed coffee-script latest and stable back to 1.12.7 for now.

@GeoffreyBooth thank you :-).

So I assume the emergency is over, now that latest points to 1.12.7?

While you’re here, does anyone know how we could print this error only on direct installs, i.e. when coffee-script is in the user’s package.json, as opposed to coffee-script being installed as a dependency of some other package? Or looked at in another way, within the context of the postinstall script is there a way to detect whether we’re being installed directly versus as a dependency? See #4759.

@GeoffreyBooth I think what you are looking for is something like; (not tested)

var fs = require('fs'),
  path = require('path');

function readJsonFile(filePath) {
  try {
    var data = fs.readFileSync(filePath, 'utf-8');
    return JSON.parse(data);
  } catch (error) {
    return null;
  }
}

var pgkCoffeeData = readJsonFile('./package.json');
if (!pgkCoffeeData || !pgkCoffeeData._where || pgkCoffeeData._where.indexOf('node_modules') !== -1) {
  return;
}

var pgkData = readJsonFile(path.join(pgkCoffeeData._where, './package.json'));
if (!pgkData) {
  return;
}

var hasOldCoffeScript = (pgkData.dependencies && pgkData.dependencies['coffee-script'])
  || (pgkData.devDependencies && pgkData.devDependencies['coffee-script']);

if (hasOldCoffeScript) {
   // oops old script is 
}

Updated implementation for anyone looking into this from the future :)

Actual implementation: https://github.com/jashkenas/coffeescript/pull/4807/files

4O4 commented

@GeoffreyBooth Why not just use npm-deprecate ? It's simple, built-in, fits your use case and you definitely can't break thousands of random projects with that πŸ˜ƒ

@GeoffreyBooth just tested it, the emergency is over

Though I have no clue how we have a dependency on coffee-script: it's not in our package.json and not in the dependency tree when printing it with "npm ls"

@SwintDC thanks πŸ˜„

@4O4 #4759 (comment)

@alan-agius4 Let’s discuss in #4807. If there’s anyone with Windows or CI environments that can help us test, please check out that PR. I’ll aim to push a fix on Friday night, so that at least there’s the weekend for any flood of new problems. Sorry for the headache everyone.

I have until tonight to npm unpublish 1.12.8 if we want, but I’m not sure there’s a point in doing so? The 1.12.8 version can’t be reused even after I unpublish, so the fix will be in 1.12.9 regardless.

4O4 commented

@GabrielRatener IMHO it makes perfect sense to unpublish 1.12.8. It's faulty release, don't let anyone ever install it again for your own peace of mind.

Okay, I’ve unpublished coffee-script@1.12.8 and coffeescript@1.12.8.