gonzofish / angular-librarian

An Angular 2+ scaffolding setup for creating libraries
https://www.npmjs.com/package/angular-librarian
MIT License
91 stars 9 forks source link

npm pack using wrong path with scoped package #80

Closed matthiaskern closed 6 years ago

matthiaskern commented 7 years ago

First of all, great project! Thank you for publishing this!

I've noticed that npm pack and in the end npm publish try to use a path without @ and thus fail. This can be reproduced with a new install and a name like @scope/library. Renaming the @scope folder inside /dist to scope solves the issue. Could this be an npm issue? All paths inside package.json seem to be correct.

node -v
v8.9.0

npm -v
5.5.1
npm pack
(node:80697) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: ENOENT: no such file or directory, stat '/Users/matt/Code/librarian-test/dist/test/librarian-test.es5.js'
(node:80697) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
npm ERR! cb() never called!

npm ERR! This is an error with npm itself. Please report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/matt/.npm/_logs/2017-11-08T13_19_19_683Z-debug.log

package.json

{
  "name": "@test/librarian-test",
  "version": "0.0.0",
  "description": "Librarian Test, an Angular library",
  "main": "./bundles/librarian-test.umd.js",
  "scripts": {
    "test": "node ./tasks/test",
    "build": "node ./tasks/build",
    "g": "node ./node_modules/angular-librarian",
    "lint": "tslint ./src/**/*.ts",
    "postbuild": "rimraf build",
    "posttagVersion": "npm run build && npm publish dist",
    "prebuild": "rimraf dist out-tsc",
    "start": "webpack-dev-server --open --config ./webpack/webpack.dev.js",
    "tagVersion": "np --no-publish"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "angular-librarian": "1.0.0-beta.14",
    "@angular/compiler-cli": "^4.0.0",
    "@types/jasmine": "2.5.38",
    "@types/node": "^6.0.42",
    "angular2-template-loader": "0.6.0",
    "awesome-typescript-loader": "^3.0.0",
    "codelyzer": "~3.0.0",
    "css-loader": "^0.26.1",
    "css-to-string-loader": "^0.1.3",
    "extract-text-webpack-plugin": "^2.1.0",
    "file-loader": "^0.8.5",
    "fs-extra": "^2.1.2",
    "html-webpack-plugin": "^2.19.0",
    "istanbul-instrumenter-loader": "^1.2.0",
    "jasmine-core": "2.5.2",
    "jasmine-spec-reporter": "2.5.0",
    "karma": "1.2.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-coverage-istanbul-reporter": "^1.3.0",
    "karma-jasmine": "^1.0.2",
    "karma-phantomjs-launcher": "^1.0.2",
    "karma-sourcemap-loader": "^0.3.7",
    "karma-webpack": "^2.0.0",
    "node-sass": "^4.1.1",
    "np": "^2.12.0",
    "phantomjs-prebuilt": "^2.1.7",
    "raw-loader": "^0.5.1",
    "rimraf": "^2.5.3",
    "rollup": "0.43.0",
    "rollup-plugin-commonjs": "^8.0.2",
    "rollup-plugin-node-resolve": "3.0.0",
    "rollup-plugin-sourcemaps": "0.4.2",
    "rollup-plugin-uglify": "2.0.1",
    "sass-loader": "^4.0.1",
    "script-loader": "^0.7.0",
    "semver": "5.3.0",
    "source-map-loader": "^0.1.5",
    "style-loader": "^0.13.1",
    "tslint": "^5.0.0",
    "tslint-loader": "^3.0.0",
    "typescript": "~2.2.1",
    "typings": "^0.8.1",
    "url-loader": "^0.5.7",
    "webpack": "^2.2.0",
    "webpack-dev-server": "^2.2.0",
    "webpack-merge": "^0.14.0",
    "webpack-node-externals": "^1.5.4"
  },
  "module": "./@test/librarian-test.es5.js",
  "es2015": "./@test/librarian-test.js",
  "typings": "./librarian-test.d.ts",
  "dependencies": {
    "@angular/common": "^4.0.0",
    "@angular/compiler": "^4.0.0",
    "@angular/core": "^4.0.0",
    "@angular/platform-browser": "^4.0.0",
    "@angular/platform-browser-dynamic": "^4.0.0",
    "core-js": "^2.4.1",
    "rxjs": "^5.0.1",
    "zone.js": "0.8.12"
  },
  "repository": {
    "url": "12"
  }
}
matthiaskern commented 7 years ago

I've noticed this only after trying npm run tagVersion failing with that, and trying to do it manually. Seems like np has problems with scoped packages at the moment. I had similar problems as described in here https://github.com/sindresorhus/np/issues/190

Edit: It's reproducable here https://github.com/matthiaskern/librarian-test

gonzofish commented 7 years ago

This is interesting, thanks for bringing it up.

I've published a scoped package before to test (it's located here), but I'll give it a go again since it hasn't been done in 3 months

gonzofish commented 7 years ago

You're right, there seems to be something odd happening with np, I'll see if I can work around it

gonzofish commented 7 years ago

I think NPM is the issue, as you first mentioned: https://github.com/npm/npm/issues/18658

gonzofish commented 7 years ago

I'd say, if you can (for now), roll back to NPM 5.3 and wait for this fix to land and we can revisit it

matthiaskern commented 7 years ago

:+1: Thanks for the help with investigating

gonzofish commented 7 years ago

Not a problem, I'm a little surprised that NPM has such a bug--but it is just software, so it happens

litzebauer commented 7 years ago

I'm having an issue with np too and I don't have scoped package. Getting spawnSync np ENOENT

litzebauer commented 7 years ago

If I install np globally and run np --yolo --no-yarn it works so its something with the way angular-librarian is calling np

gonzofish commented 7 years ago

Are you certain that np is installed in your local project? Something like an ENOENT is not the same as the issue here

litzebauer commented 7 years ago

Yes I am certain it is installed in the local project. It might be the same issue because @matthiaskern says that npm run tagVersion fails.

gonzofish commented 7 years ago

@matthiaskern is failing after np has finished and the build script has finished running because NPM > 5.3.0 is stripping special characters (in this case the @ symbol)

litzebauer commented 7 years ago

Ok, I guess I need to open a new issue.

matthiaskern commented 7 years ago

I was hit by two issues, first of all npm run tagVersion with yarn failing, it removed dependencies before running the tests, but that's already described in the np repo. Then when I tried manually I noticed the other issue you found above with npm itself. npm run tagVersion -- --yolo might work, but I can't try it out right now.

gonzofish commented 6 years ago

@matthiaskern I think you should be good with the 1.0.0 release. We needed to move the np library out of project dependencies to support using it (see the migration guide)