Skip to content

fix: Update npx command line#496

Closed
pvdlg wants to merge 1 commit intocariboufrom
npx-cmd
Closed

fix: Update npx command line#496
pvdlg wants to merge 1 commit intocariboufrom
npx-cmd

Conversation

@pvdlg
Copy link
Copy Markdown
Member

@pvdlg pvdlg commented Oct 30, 2017

@pvdlg pvdlg requested a review from gr2m October 30, 2017 14:59
gr2m added a commit to gr2m/semantic-release-cli-test that referenced this pull request Oct 30, 2017
@gr2m
Copy link
Copy Markdown
Member

gr2m commented Oct 30, 2017

I've tested the new command but got an error:
https://travis-ci.org/gr2m/semantic-release-cli-test#L564

It looks like it cannot access NPM_TOKEN but it is set at https://travis-ci.org/gr2m/semantic-release-cli-test#L422

I'll look more into it

@gr2m gr2m self-assigned this Oct 30, 2017
@gr2m
Copy link
Copy Markdown
Member

gr2m commented Oct 30, 2017

I don't think it's the access to the environment variable, but the location of the .npmrc file

@gr2m
Copy link
Copy Markdown
Member

gr2m commented Oct 30, 2017

@pvdlg by the way the %O placeholder doesn't get replaced correctly: https://travis-ci.org/gr2m/semantic-release-cli-test#L564, I don't know why, works for me when testing locally with Node 8

> console.error('test 12 %O', new Error('funky'))
test 12 Error: funky
    at repl:1:29
    at ContextifyScript.Script.runInThisContext (vm.js:50:33)
    at REPLServer.defaultEval (repl.js:240:29)
    at bound (domain.js:301:14)
    at REPLServer.runBound [as eval] (domain.js:314:12)
    at REPLServer.onLine (repl.js:441:10)
    at emitOne (events.js:120:20)
    at REPLServer.emit (events.js:210:7)
    at REPLServer.Interface._onLine (readline.js:282:10)
    at REPLServer.Interface._line (readline.js:631:8)

But it doesn't when running in Node 6 or 4. Maybe the execa is messing with the npx command somehow?

@pvdlg
Copy link
Copy Markdown
Member Author

pvdlg commented Oct 30, 2017

Yes I noticed that as well. I'm looking at it.

@pvdlg
Copy link
Copy Markdown
Member Author

pvdlg commented Oct 30, 2017

On a local project if I run npx -p node@8 -c "semantic-release"
I get the error: /bin/sh: semantic-release: command not found

If I have semantic-release installed globally it works.

I'm really confused by what npx -p node@8 -c "semantic-release" actually does...
The problem with the NPM_TOKEN missing might be due to semantic-release not being executed from the root directory of the project...

@pvdlg
Copy link
Copy Markdown
Member Author

pvdlg commented Oct 30, 2017

Running on Node 8:

node -e "console.log('TEST %O', {a: 1})"
=> TEST { a: 1 }
npx -p node@8 -c "node -e \"console.log('TEST %O', {a: 1})\""
=> TEST %O { a: 1 }

¯_(ツ)_/¯

@pvdlg
Copy link
Copy Markdown
Member Author

pvdlg commented Oct 30, 2017

Ok the %O problem is due to nodejs/node#14558 that has been implemented in Node 8.4.0.

When running npx -p node@8 the version used is 8.3.0 as it's the latests published on npm.

So we can either decide to support only node >=8.4.0 or I'll have to find another way to format objects in logs. I'm sure their library that can do that.

@gr2m
Copy link
Copy Markdown
Member

gr2m commented Nov 1, 2017

I'm okay with supporting only Node >=8.9 as it became LTS today 🎉

npx -p node@8 -c "node -e "console.log('TEST %O', {a: 1})""
=> TEST %O { a: 1 }

I was not able to reproduce this ¯\_(ツ)_/¯

My guess it had an older Node 8 version installed and because it matched the wanted node version it used the local version instead of getting the latest? Try

npx -p node@8.9.0 -c "node -e \"console.log('TEST %O', {a: 1})\""

@gr2m
Copy link
Copy Markdown
Member

gr2m commented Nov 1, 2017

by the way node is just an npm package: https://www.npmjs.com/package/node. So npx installs the node package and runs the command string against its binary, I guess

@gr2m
Copy link
Copy Markdown
Member

gr2m commented Nov 1, 2017

I get the error: /bin/sh: semantic-release: command not found

can you try the --shell-auto-fallback flag?

Docs say

--shell-auto-fallback [] - Generates shell code to override your shell's "command not found" handler with one that calls npx. Tries to figure out your shell, or you can pass its name (either bash, fish, or zsh) as an option. See below for how to install.

@pvdlg
Copy link
Copy Markdown
Member Author

pvdlg commented Nov 1, 2017

I was not able to reproduce this ¯_(ツ)_/¯

It happens with node <= 8.4.0
So npx -p node@8.3.0 -c "node -e "console.log('TEST %O', {a: 1})"" would create the problem with %O.
Since today the last of node@8 release on npm is 8.9.0, so npx -p node@8 works.

@pvdlg
Copy link
Copy Markdown
Member Author

pvdlg commented Nov 1, 2017

can you try the --shell-auto-fallback flag?

Now running npx -p node@8 -c "semantic-release" works... I don't have /bin/sh: semantic-release: command not found

Maybe a weird bug somewhere between a specific version of node / npx / npm?

Comment thread README.md
Being able to write code for just the most recent node versions greatly simplifies development. More language features are available, no transpilation is required, less test builds are to be run, awaited and debugged.

For a special purpose tool like `semantic-release`, that's only meant to be used in controlled CI environments, we think it's okay to have such a high version requirement. As `semantic-release` handles package publishing we expect almost every project to have at least one build job running node 8 already – and that's all it takes. Even if that's not that case `semantic-release` can still be executed with the help of [npx](https://www.npmjs.com/package/npx) (`npx -p node@8 npm run semantic-release`).
For a special purpose tool like `semantic-release`, that's only meant to be used in controlled CI environments, we think it's okay to have such a high version requirement. As `semantic-release` handles package publishing we expect almost every project to have at least one build job running node 8 already – and that's all it takes. Even if that's not that case `semantic-release` can still be executed with the help of [npx](https://www.npmjs.com/package/npx) (`npx -p node@8 -c "semantic-release"`).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should also be mentioned that if you're using Travis build stages, you have the freedom to specify a separate node version for that stage anyway

@pvdlg
Copy link
Copy Markdown
Member Author

pvdlg commented Jan 5, 2018

Fixed by #593

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.

3 participants