question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not all NPM scripts are executed during deployment

See original GitHub issue

According to the NPM docs prepublish script should be executed on local npm install without any arguments. It seems that on Now it is not the case.

I depend on this to compile my sources (e.g. coffee, elm -> js).

Consider this sample package to test scripts execution. This is the output on my local machine:

$ npm install

> npm-scripts@1.0.0 preinstall /Users/tadeuszlazurski/Projects/npm-scripts
> echo 'NPM SCRIPT: preinstall'

NPM SCRIPT: preinstall
|
> npm-scripts@1.0.0 install /Users/tadeuszlazurski/Projects/npm-scripts
> echo 'NPM SCRIPT: install'

NPM SCRIPT: install

> npm-scripts@1.0.0 postinstall /Users/tadeuszlazurski/Projects/npm-scripts
> echo 'NPM SCRIPT: postinstall'

NPM SCRIPT: postinstall

> npm-scripts@1.0.0 prepublish /Users/tadeuszlazurski/Projects/npm-scripts
> echo 'NPM SCRIPT: prepublish'

NPM SCRIPT: prepublish
coffee-script@1.10.0 node_modules/coffee-script

lodash@3.10.1 node_modules/lodash

and this is output from now:

 $ now
> Deploying ~/Projects/npm-scripts
> Using Node.js 6.2.1 (default)
> Ready! https://npm-scripts-izbtgitqee.now.sh (copied to clipboard) [3s]
> Upload [====================] 100% 0.0s
> Sync complete (25.9kB) [3s]
> Initializing…
> Building
> ▲ npm install
> Installing package lodash@^3.10.1
> Installing package coffee-script@^1.9.3
> ▲ npm start
> NPM SCRIPT: prestart
> NPM SCRIPT: start
> NPM SCRIPT: poststart
> start exited with status 0

As you can see none of the following scripts:

  • preinstall
  • install
  • postinstall
  • prepublish

was executed in Now.

@lzrski

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:5
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
addyosmanicommented, Oct 9, 2016

I unfortunately ran into this problem today. None of the preinstall and postinstall scripts I had in my package were being successfully run using Now during deployment.

1reaction
tad-lispycommented, Dec 4, 2016

The workaround is to deploy a Docker image that contains your Node app.

Read more comments on GitHub >

github_iconTop Results From Across the Web

scripts - npm Docs
These all can be executed by running npm run-script <stage> or npm run ... Does not run during npm publish , but does...
Read more >
npm script does not run through npm run <script-name> but ...
I am trying to deploy an application on an aws linux machine. I wrote scripts to be run on Linux (for when I...
Read more >
Job can run successful without executing all script commands ...
The Windows version does not always execute all commands of the job's script. The script execution can somehow get interrupted by a command....
Read more >
npm Scripts: Tips Everyone Should Know - Corgibytes
Every script in npm runs three separate scripts under the hood. A pre script, a script itself and a post script. Those two...
Read more >
Testing and deploying with ordered npm run scripts
Run scripts before deploying ... Using the command npm run deploy in your terminal will start the publishing process. ... Prepending pre or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found