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

prepublish lifecycle script has been deprecated in npm@^4 #243

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kzap
Copy link

@kzap kzap commented Aug 14, 2017

See http://blog.lholmquist.org/npm-prepublish-changes/

Long story short, when using npm4+ and docpress/docpress-base, it wont build using docpress build if you are using a git repository as your package source instead of npm, even though its the exact same version.

The reason was there is no cache dir being build for docpress-base if the npm package was included this way (even if its the exact same package as the one on npm)

The solution I found was to use the new script lifecycle commands prepublishOnly and prepare.

Replication

Prerequsites

  • nodejs v8.2.1
  • npm 5.3.0

Steps

  1. Initialize a new project via npm
npm init
  1. Install docpress via npm
npm install --save-dev docpress
  1. Create a README file
echo "# README" >> README.md
  1. Run docpress serve to test if its working
docpress serve

  Docpress
  starting development - ^C to exit

   236ms    first build
    ✓ on    livereload
    ✓ on    http://localhost:3000

            Running
  1. Open package-lock.json or npm-shrinkwrap.json and replace
"docpress-base": {
      "version": "0.7.4",
      "resolved": "https://registry.npmjs.org/docpress-base/-/docpress-base-0.7.4.tgz",
      "integrity": "sha1-t/LcIIWJf+fJidy+RtSpG/H/1D4=",

with:

"docpress-base": {
      "version": "git+https://github.com/kzap/docpress-base.git#0.7.4",

This is the exact same version as released on npm, we are just using GitHub as the source instead

  1. Run docpress serve again to see if it works
$ docpress serve

  Docpress
  starting development - ^C to exit

   err ✗    first build
     ···    livereload
     ···    http://localhost:3000

            Starting up...

  ✗ /Users/username/docpress-test/node_modules/docpress-base/css/variables.styl:1:10
   1| @require './iconfonts/stylesheets/ionicons'
    ✓ on    livereload
   2|
   3| $bg ?= white
   4| $black ?= #111

failed to locate @require file ./iconfonts/stylesheets/ionicons.styl

    1| @require './iconfonts/stylesheets/ionicons'
    ---------------^
    2|
    3| $bg ?= white
    4| $black ?= #111

    failed to locate @require file ./iconfonts/stylesheets/ionicons.styl

    at Evaluator.visitImport (/Users/username/docpress-test/node_modules/stylus/lib/visitor/evaluator.js:915:21)
    at Evaluator.Visitor.visit (/Users/username/docpress-test/node_modules/stylus/lib/visitor/index.js:28:40)
    at Evaluator.visit (/Users/username/docpress-test/node_modules/stylus/lib/visitor/evaluator.js:160:18)
    at Evaluator.visitBlock (/Users/username/docpress-test/node_modules/stylus/lib/visitor/evaluator.js:720:39)
    at Evaluator.Visitor.visit (/Users/username/docpress-test/node_modules/stylus/lib/visitor/index.js:28:40)
    at Evaluator.visit (/Users/username/docpress-test/node_modules/stylus/lib/visitor/evaluator.js:160:18)
    at Evaluator.importFile (/Users/username/docpress-test/node_modules/stylus/lib/visitor/evaluator.js:99:18)
    at Evaluator.visitImport (/Users/username/docpress-test/node_modules/stylus/lib/visitor/evaluator.js:920:27)
    at Evaluator.Visitor.visit (/Users/username/docpress-test/node_modules/stylus/lib/visitor/index.js:28:40)
    at Evaluator.visit (/Users/username/docpress-test/node_modules/stylus/lib/visitor/evaluator.js:160:18)

events.js:182
      throw er; // Unhandled 'error' event
      ^

The above error is caused by the missingnode_modules/docpress-base/cache directory and the contents that get built in there

@coveralls
Copy link

coveralls commented Aug 14, 2017

Coverage Status

Coverage increased (+3.1%) to 84.293% when pulling 9bc77cf on kzap:feature/npm-prepare into 3eacc60 on docpress:master.

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

Successfully merging this pull request may close these issues.

2 participants