Strange errors in postinstall script #2397

Closed
paulmillr opened this Issue Apr 26, 2012 · 5 comments

Comments

Projects
None yet
4 participants
Contributor

paulmillr commented Apr 26, 2012

The thing is: i'm using coffeescript and writing node.js modules in it.

  • After each install of any module postinstall is ran which compiles all src/ coffeescripts to lib/ js. This allows to not store files in repo. prepublish wouldn't work here because sometimes you'll want to use github version.
  • "postinstall": "coffee -o lib/ src/" won't work because user might not have globally installed coffeescript on his system. So then i've decided to use local coffees with every package:
  • "postinstall": "./node_modules/coffee-script/bin/coffee -o lib/ src/". But it doesn't work on windows because it has different paths. So then i've decided to use a file in current working directory:
  • "postinstall": "node setup.js compileCoffeeScripts". I've created a syntax sugar for coffeescript projects called beare in order to not repeat routine in all coffee projects.

I'm trying to use it in brunch master and it fails with strange errors like this.

Brunch uses chokidar package which uses beare too.

npm http GET https://registry.npmjs.org/coffee-script/1.3.1
npm http GET https://registry.npmjs.org/argumentum/0.6.0
npm http GET https://registry.npmjs.org/async/0.1.18
npm http GET https://registry.npmjs.org/mkdirp/0.3.0
npm http GET https://registry.npmjs.org/ncp/0.2.6
npm http GET https://registry.npmjs.org/rimraf/2.0.1
npm http GET https://registry.npmjs.org/growl/1.5.0
npm http GET https://registry.npmjs.org/express/2.5.8
npm http GET https://registry.npmjs.org/date-utils/1.2.10
npm http GET https://registry.npmjs.org/ansi-color/0.2.1
npm http GET https://registry.npmjs.org/beare/0.1.1
npm http GET https://registry.npmjs.org/chokidar/0.1.1
npm http GET https://registry.npmjs.org/mocha/1.0.1
npm http GET https://registry.npmjs.org/expect.js/0.1.2
npm http 304 https://registry.npmjs.org/mkdirp/0.3.0
npm http 304 https://registry.npmjs.org/coffee-script/1.3.1
npm http 304 https://registry.npmjs.org/async/0.1.18
npm http 304 https://registry.npmjs.org/argumentum/0.6.0
npm http 304 https://registry.npmjs.org/ncp/0.2.6
npm http 304 https://registry.npmjs.org/rimraf/2.0.1
npm http 304 https://registry.npmjs.org/growl/1.5.0
npm http 304 https://registry.npmjs.org/express/2.5.8
npm http 304 https://registry.npmjs.org/date-utils/1.2.10
npm http 304 https://registry.npmjs.org/ansi-color/0.2.1
npm http 304 https://registry.npmjs.org/beare/0.1.1
npm http 304 https://registry.npmjs.org/chokidar/0.1.1
npm http 304 https://registry.npmjs.org/mocha/1.0.1
npm http 304 https://registry.npmjs.org/expect.js/0.1.2

> chokidar@0.1.1 postinstall /Users/paul/Development/brunch/brunch/node_modules/chokidar
> node beare.js compileCoffeeScripts

npm http GET https://registry.npmjs.org/graceful-fs

node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
Error: Cannot find module 'coffee-script'
    at Function._resolveFilename (module.js:332:11)
    at Function._load (module.js:279:25)
    at Module.require (module.js:354:17)
    at require (module.js:370:17)
    at Object.<anonymous> (/Users/paul/Development/brunch/brunch/node_modules/beare/lib/index.js:2:20)
    at Module._compile (module.js:441:26)
    at Object..js (module.js:459:10)
    at Module.load (module.js:348:31)
    at Function._load (module.js:308:12)
    at Module.require (module.js:354:17)

npm ERR! chokidar@0.1.1 postinstall: `node beare.js compileCoffeeScripts`
npm ERR! `sh "-c" "node beare.js compileCoffeeScripts"` failed with 1
npm ERR! 
npm ERR! Failed at the chokidar@0.1.1 postinstall script.
npm ERR! This is most likely a problem with the chokidar package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node beare.js compileCoffeeScripts
npm ERR! You can get their info via:
npm ERR!     npm owner ls chokidar
npm ERR! There is likely additional logging output above.
npm ERR! 
npm ERR! System Darwin 12.0.0
npm ERR! command "node" "/usr/local/bin/npm" "install"
npm ERR! cwd /Users/paul/Development/brunch/brunch
npm ERR! node -v v0.6.14
npm ERR! npm -v 1.1.18
npm ERR! code ELIFECYCLE
npm ERR! message chokidar@0.1.1 postinstall: `node beare.js compileCoffeeScripts`
npm ERR! message `sh "-c" "node beare.js compileCoffeeScripts"` failed with 1
npm ERR! errno {}
npm http GET https://registry.npmjs.org/mime/1.2.4
npm http GET https://registry.npmjs.org/connect
npm http GET https://registry.npmjs.org/qs
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/paul/Development/brunch/brunch/npm-debug.log
npm not ok

fkiller commented Jun 29, 2012

I have a similar issue as well installing webkit-server in Ubuntu. That was because a shell should be executed by bash but by sh. npm config has shell key with the value of "bash" in my environment, but it wasn't applied.

Hi, have you solved this problem?

Member

timoxley commented Jan 7, 2014

@paulmillr Is this still a problem? any npm scripts in your package.json get ./node_modules/.bin automatically on their $PATH, but generally your published modules shouldn't even need to know coffee-script exists. Ideally coffee-script exists only as a dev dependency and the code published to npm will use npm's prepublish to compile. Is there a reason this doesn't work for you?

The setup.js in brunch seems "not right" to me.

But it doesn't work on windows because it has different paths

What different paths?

#4430

Contributor

paulmillr commented Jan 7, 2014

sorry, i don't know — i've thrown coffee away in most node projects. was tired of similar issues over and over.

Member

timoxley commented Jan 7, 2014

@paulmillr ok, a shame. Can you close this if it's no longer required?

paulmillr closed this Jan 7, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment