npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

npm prefix flag does not work as expected on windows

Hello, I’m running into an issue that does not happen on Mac, but does happen on Windows.
I have a project that lays down files and installs in the folder that was just laid down, the effective command it runs is “npm --prefix install”. This however causes an error on windows:

npm ERR! code ENOLOCAL
npm ERR! Could not install from "" as it does not contain a package.json file.

Here is the full log:

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   '--prefix',
1 verbose cli   'C:\\Users\\jrjur\\Programs\\test\\',
1 verbose cli   'install' ]
2 info using npm@6.4.1
3 info using node@v11.1.0
4 verbose npm-session 59fa294aa88ba17f
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 silly fetchPackageMetaData error for file: Could not install from "" as it does not contain a package.json file.
8 timing stage:rollbackFailedOptional Completed in 2ms
9 timing stage:runTopLevelLifecycles Completed in 1102ms
10 verbose stack Error: ENOENT: no such file or directory, open 'C:\Users\jrjur\Programs\package.json'
11 verbose cwd C:\Users\jrjur\Programs
12 verbose Windows_NT 10.0.17134
13 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "--prefix" "C:\\Users\\jrjur\\Programs\\test\\" "install"
14 verbose node v11.1.0
15 verbose npm  v6.4.1
16 error code ENOLOCAL
17 error Could not install from "" as it does not contain a package.json file.
18 verbose exit [ 1, true ]

Line 7 appears to specifically be where the error occurs, however I have no idea what “fetchPackageMetaData” does or what directory it’s trying to read from…

The directory that is laid down DOES have a package.json, and if I cd into the directory, I can do a normal npm install with no issues… Again, this issue is only on Windows, it does not occur on Mac OS X.

If it is helpful, this is the generator that is running into the issue (the issue can be reproduced by running npx tram-one-express test-project):

Has this been resolved ? If yes, Could you please let me know, how to fix this issue?