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

[BUG] (windows) npm@8.3.1 --prefix or --cwd not working with 'install', WARN Ignoring workspaces for specified package(s) #4511

Open
2 tasks done
maxmag-soft opened this issue Mar 3, 2022 · 7 comments
Labels
Bug thing that needs fixing platform:windows is Windows-specific Priority 2 secondary priority issue Release 8.x work is associated with a specific npm 8 release

Comments

@maxmag-soft
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

`
D:\git_projects\arcadia>npm --prefix "%PWD%%PROJECT%" --cwd "%PWD%%PROJECT%" run dev
npm WARN Ignoring workspaces for specified package(s)

D:\git_projects\arcadia>npm --cwd "%PWD%%PROJECT%" install
npm WARN Ignoring workspaces for specified package(s)

D:\git_projects\arcadia>npm --prefix "%PWD%%PROJECT%" install
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path D:\git_projects\arcadia/package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'D:\git_projects\arcadia\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! C:\Users\😊\AppData\Local\npm-cache_logs\2022-03-02T19_34_03_309Z-debug-0.log

D:\git_projects\arcadia>npm --cwd "%PWD%%PROJECT%" install --loglevel verbose
npm verb cli [
npm verb cli 'C:\Program Files\nodejs\node.exe',
npm verb cli 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js',
npm verb cli '--cwd',
npm verb cli 'D:\git_projects\arcadia\arcadia',
npm verb cli 'install',
npm verb cli '--loglevel',
npm verb cli 'verbose'
npm verb cli ]
npm info using npm@8.3.1
npm info using node@v16.14.0
npm timing npm:load:whichnode Completed in 1ms
npm timing config:load:defaults Completed in 4ms
npm timing config:load:file:D:\m_portable\nodejs\APP_PORTABLE\node_modules\npm\npmrc Completed in 7ms
npm timing config:load:builtin Completed in 8ms
npm timing config:load:cli Completed in 8ms
npm timing config:load:env Completed in 1ms
npm timing config:load:file:D:\git_projects\arcadia.npmrc Completed in 0ms
npm timing config:load:project Completed in 8ms
npm timing config:load:file:C:\Users\😊.npmrc Completed in 0ms
npm timing config:load:user Completed in 1ms
npm timing config:load:file:C:\Users\😊\AppData\Roaming\npm\etc\npmrc Completed in 0ms
npm timing config:load:global Completed in 1ms
npm timing config:load:validate Completed in 0ms
npm timing config:load:credentials Completed in 3ms
npm timing config:load:setEnvs Completed in 2ms
npm timing config:load Completed in 37ms
npm timing npm:load:configload Completed in 39ms
npm timing npm:load:setTitle Completed in 1ms
npm timing config:load:flatten Completed in 8ms
npm timing npm:load:display Completed in 67ms
npm verb logfile C:\Users\😊\AppData\Local\npm-cache_logs\2022-03-02T19_42_49_495Z-debug-0.log
npm timing npm:load:logFile Completed in 40ms
npm timing npm:load:timers Completed in 0ms
npm timing npm:load:configScope Completed in 0ms
npm timing npm:load Completed in 157ms
npm WARN Ignoring workspaces for specified package(s)
npm timing command:info Completed in 129ms
npm verb exit 0
npm timing npm Completed in 885ms
npm info ok`

Expected Behavior

`
D:\git_projects\arcadia>cd arcadia

D:\git_projects\arcadia\arcadia>npm install --loglevel verbose
npm verb cli [
npm verb cli 'C:\Program Files\nodejs\node.exe',
npm verb cli 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js',
npm verb cli 'install',
npm verb cli '--loglevel',
npm verb cli 'verbose'
npm verb cli ]
npm info using npm@8.3.1
npm info using node@v16.14.0
npm timing npm:load:whichnode Completed in 2ms
npm timing config:load:defaults Completed in 4ms
npm timing config:load:file:D:\m_portable\nodejs\APP_PORTABLE\node_modules\npm\npmrc Completed in 8ms
npm timing config:load:builtin Completed in 8ms
npm timing config:load:cli Completed in 8ms
npm timing config:load:env Completed in 2ms
npm timing config:load:file:D:\git_projects\arcadia\arcadia.npmrc Completed in 6ms
npm timing config:load:project Completed in 9ms
npm timing config:load:file:C:\Users\😊.npmrc Completed in 0ms
npm timing config:load:user Completed in 1ms
npm timing config:load:file:C:\Users\😊\AppData\Roaming\npm\etc\npmrc Completed in 0ms
npm timing config:load:global Completed in 1ms
npm timing config:load:validate Completed in 1ms
npm timing config:load:credentials Completed in 3ms
npm timing config:load:setEnvs Completed in 4ms
npm timing config:load Completed in 42ms
npm timing npm:load:configload Completed in 43ms
npm timing npm:load:setTitle Completed in 1ms
npm timing config:load:flatten Completed in 12ms
npm timing npm:load:display Completed in 83ms
npm verb logfile C:\Users\😊\AppData\Local\npm-cache_logs\2022-03-02T19_46_58_104Z-debug-0.log
npm timing npm:load:logFile Completed in 60ms
npm timing npm:load:timers Completed in 0ms
npm timing npm:load:configScope Completed in 0ms
npm timing npm:load Completed in 203ms
npm timing arborist:ctor Completed in 3ms
npm timing arborist:ctor Completed in 0ms
npm timing idealTree:init Completed in 51ms
npm timing idealTree:userRequests Completed in 1ms
npm http fetch GET 200 https://registry.npmjs.org/@next-auth%2fmongodb-adapter 2460ms (cache miss)
npm http fetch GET 200 https://registry.npmjs.org/mongodb 229ms (cache miss)
npm http fetch GET 200 https://registry.npmjs.org/next-auth 189ms (cache miss)

`

Steps To Reproduce

  1. In this environment...
    Windows 11 64 bits latest
  2. With this config...
    nodejs = v16.14.0 // npm = 8.3.1
  3. Run '...'
    npm --cwd or --prefix install or run dev, anything will not make npm process files on subfolder, only when entering package.json folder
  4. See error...
    npm WARN Ignoring workspaces for specified package(s)

Environment

  • npm: 8.3.1
  • Node.js: 16.14.0
  • OS Name: Windows 11 x64 latest no WSL
  • System Model Name: Notebook Avell 256GB NVME 16GB DDR4 NVME RTX 2070 MaxQ
  • npm config:
; copy and paste output from `npm config ls` here
; "builtin" config from D:\m_portable\nodejs\APP_PORTABLE\node_modules\npm\npmrc

prefix = "C:\\Users\\😊\\AppData\\Roaming\\npm"

; node bin location = C:\Program Files\nodejs\node.exe
; cwd = D:\git_projects\arcadia
; HOME = C:\Users\😊
; Run `npm config ls -l` to show all defaults.
@maxmag-soft maxmag-soft added Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release labels Mar 3, 2022
@maxmag-soft
Copy link
Author

maxmag-soft commented Mar 4, 2022

This --prefix worked back in NPM 8.1.2 in Windows and Linux
Now, they don't
Tested on ArchLinux npm 8.5.2

@nlf
Copy link
Contributor

nlf commented Mar 7, 2022

i'm not following what's happening here.. i would note that --cwd isn't a config flag with any meaning in npm>=7

can you tell us more about your directory structure and what you're trying to do? are you using workspaces?

@maxmag-soft
Copy link
Author

maxmag-soft commented Mar 7, 2022

Hi nlf,
I have a git repo in /home/user/dev/myrepo/
inside I have a next.js project in /home/user/dev/myrepo/arcadia/
I wanted to run npm commands install/build/dev/etc while I am at the repo folder, not inside my project folder (the package.json folder)
no, its not a workspace

├── my_repo
│   ├── arcadia
│   │   ├── package.json
│   │   ├── next.config.js
│   │   ├── node_modules

my workaround is this:
downloading node and npm from official site and changing path variable.
export PATH="$PWD/nodejs/node-v16.13.2-linux-x64/bin:$PATH"
npm --prefix $PWD/arcadia install
npm --version
8.1.2
node --version
v16.13.2

@nlf
Copy link
Contributor

nlf commented Mar 8, 2022

i was able to reproduce this following these steps, please let me know if i missed anything:

> mkdir repo_root
> cd repo_root
> git init
> mkdir project
> cd project
> npm init -y
# installing a dependency in the project just so we can see it's doing something
> npm i debug
> cd ..
> npm --prefix ./project install
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:\Users\username\Projects\temp\root/package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\username\Projects\temp\root\package.json'
npm ERR! enoent This is related to npm not being able to find a file.

which sure makes it look as though we're disregarding the --prefix parameter entirely. it's worth noting, the same series of commands run in osx and linux works correctly, however attempts in bash, cmd, and powershell all fail in windows. interestingly npm --prefix ./project prefix does print the expected result, so it seems like we're getting the prefix correctly but still trying to read the package.json from the root anyway which is absolutely a bug.

@nlf nlf added Priority 2 secondary priority issue platform:windows is Windows-specific and removed Needs Triage needs review for next steps labels Mar 8, 2022
@maxmag-soft
Copy link
Author

Yes! thats right!
if you try with npm version 8.1 it can run flawlessly on linux, (windows not tested)
I saw on the internet to try using --cwd on windows, and it didn't work on latest version yet

@enyichiaagu
Copy link

Yes! thats right! if you try with npm version 8.1 it can run flawlessly on linux, (windows not tested) I saw on the internet to try using --cwd on windows, and it didn't work on latest version yet

Hello, what workaround did you use for this issue? I'm facing something similar right now

@pseusys
Copy link

pseusys commented Jan 13, 2025

Still not working :(
Any plans on investigating and/or fixing the issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing platform:windows is Windows-specific Priority 2 secondary priority issue Release 8.x work is associated with a specific npm 8 release
Projects
None yet
Development

No branches or pull requests

4 participants