-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
[BUG] NPX does not work outside package directories #1975
Comments
If the It is okay if Tested with bash-5.0# npx serve
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /home/node/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/home/node/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-10-24T02_26_28_755Z-debug.log
bash-5.0# echo {}>package.json
bash-5.0# npx serve
UPDATE AVAILABLE The latest version of `serve` is 11.3.2
ERROR: Cannot copy to clipboard: Couldn't find the required `xsel` binary. On Debian/Ubuntu you can install it with: sudo apt install xsel
┌──────────────────────────────────────────────┐
│ │
│ Serving! │
│ │
│ - Local: http://localhost:80 │
│ - On Your Network: http://192.168.0.1:80 │
│ │
└──────────────────────────────────────────────┘ |
I confirm such behaviour on Win 10 1909 with NodeJS 15.0.1. I have a repo with directory called |
i'm not able to reproduce this with 7.0.5, is this issue still happening for you? |
Updating to npm@7.0.5 gives me another, but seemingly related, error, that is also fixed by making an empty package.json
|
the log output above shows npm 7.0.1, is that correct? you should be able to update with |
This fixes running `npm exec` in folders that does not have a `package.json` file. Fixes: npm#1975
@Nicholaiii did you get this solved with a newer version? I still have this problem with the latest node (via docker |
No. I am using |
@MoSattler @Nicholaiii thanks for the feedback! Could you please share any log files/package.json so that we can figure out why is this problem still happening? 😊 |
Fresh install of Node 15.1.0 and
There is no package.json, that's the core problem. If I make an empty one like this: |
@ruyadorno Same problem for me as for @Nicholaiii I use node in docker. # Dockerfile
FROM node:15.3.0
RUN npx cowsay Hi! Output when building is
Complete log
|
One thing I noticed is that npx now asks you if you want to install a package before it executes it before. I dont think that was the case before. |
thanks for the report @MoSattler! |
Error: ENOENT: no such file or directory, open error is not fixed '<absolute_current_directory_path>/package.json Still have the problem in npm v7.7.6 Using npx in a cwd that is a child of the root directory where package.json reside! "db:migrate": "cd src/Database && npx knex migrate:latest", This used to work! Now give the above error! Not the expected behavior! And it's breaking the usual behavior ! |
Current Behavior:
When using npx in any directory not initialised with a package.json, npx stops beacause of
ENOENT
package.json.Expected Behavior:
npx runs the command regardlessly, like it does in the one shipped with npm@6
Steps To Reproduce:
$ npm i -g npm@7
$ npx jay
(anywhere that's not in a package)Environment:
The text was updated successfully, but these errors were encountered: