Skip to content

Error while installing [email protected] 'invalid or unexpected token' #4805

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

Closed
eashi opened this issue Nov 30, 2017 · 65 comments
Closed

Error while installing [email protected] 'invalid or unexpected token' #4805

eashi opened this issue Nov 30, 2017 · 65 comments

Comments

@eashi
Copy link

eashi commented Nov 30, 2017

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 [email protected]
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

[email protected] 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! [email protected] 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 [email protected] 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

@mapohjola
Copy link

Experiencing the same thing with npm 3.10.10 on win 10

@Liam-Ryan
Copy link

Seeing the same with npm 5.3.0

@vendethiel
Copy link
Collaborator

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.

@sharmasourabh
Copy link

Same issue is there for Windows 10 and npm 5.5.1

@weihsth
Copy link

weihsth commented Nov 30, 2017

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

@4O4
Copy link

4O4 commented Nov 30, 2017

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

@vadymlab
Copy link

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.

@garvik
Copy link

garvik commented Nov 30, 2017

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
Copy link

4O4 commented Nov 30, 2017

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

image

@pmaza
Copy link

pmaza commented Nov 30, 2017

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

@meowthing
Copy link

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

@henrikmerlander
Copy link

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

@vendethiel
Copy link
Collaborator

vendethiel commented Nov 30, 2017

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
Copy link

pmaza commented Nov 30, 2017

@meowthing I've just solved it right now installing "[email protected]" as a dev dependency.
Thanks @garvik!!

@weihsth
Copy link

weihsth commented Nov 30, 2017

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

@ArturChe
Copy link

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

@GMouron
Copy link

GMouron commented Nov 30, 2017

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)

@alan-agius4
Copy link

alan-agius4 commented Nov 30, 2017 via email

@guoruiak
Copy link

Same issue is there for Windows 7 and npm 6.11.0

@BhupenderAgarwal24
Copy link

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.

@ivanromakh
Copy link

ivanromakh commented Nov 30, 2017

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

@vadymlab
Copy link

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

@rducom
Copy link

rducom commented Nov 30, 2017

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

@samuelfernandez
Copy link

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

@niftylettuce
Copy link

@Alevale
Copy link

Alevale commented Nov 30, 2017

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
^^^

@adamayoung
Copy link

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

@anthonyhumphreys
Copy link

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

@ThorMutoAsmund
Copy link

Has anyone contacted [email protected] ? He is in Stockholm and should be awake

@lluisd
Copy link

lluisd commented Nov 30, 2017

Same problem here when I tried to install i18n

@mbielkin
Copy link

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.

@GeoffreyBooth
Copy link
Collaborator

Well, now that we have your attention 😄

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

@vendethiel
Copy link
Collaborator

@GeoffreyBooth thank you :-).

@sdib
Copy link

sdib commented Nov 30, 2017

@GeoffreyBooth thanks

@GeoffreyBooth
Copy link
Collaborator

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.

@alan-agius4
Copy link

alan-agius4 commented Nov 30, 2017

@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
Copy link

4O4 commented Nov 30, 2017

@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 😃

@SwintDC
Copy link

SwintDC commented Nov 30, 2017

@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"

@GeoffreyBooth
Copy link
Collaborator

@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
Copy link

4O4 commented Nov 30, 2017

@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.

@GeoffreyBooth
Copy link
Collaborator

Okay, I’ve unpublished [email protected] and [email protected].

@GeoffreyBooth GeoffreyBooth removed the bug label Nov 30, 2017
alan-agius4 added a commit to alan-agius4/coffeescript that referenced this issue Dec 1, 2017
…is listed under `dependencies` or `devDependencies`

Closes: jashkenas#4805
alan-agius4 added a commit to alan-agius4/coffeescript that referenced this issue Dec 1, 2017
…is listed under `dependencies` or `devDependencies`

Closes: jashkenas#4805
alan-agius4 added a commit to alan-agius4/coffeescript that referenced this issue Dec 1, 2017
…is listed under `dependencies` or `devDependencies`

Closes: jashkenas#4805
alan-agius4 added a commit to alan-agius4/coffeescript that referenced this issue Dec 1, 2017
…is listed under `dependencies` or `devDependencies`

Closes: jashkenas#4805
alan-agius4 added a commit to alan-agius4/coffeescript that referenced this issue Dec 1, 2017
…is listed under `dependencies` or `devDependencies`

Closes: jashkenas#4805
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