create-yo
create-yo copied to clipboard
Error: Cannot find module 'libnpx'
I have a fresh nodejs installation in Windows 10 (i have this issue in linux too)
I already verify npm cache:
C:\Users\almancini\prova>npm cache verify
Cache verified and compressed (~\AppData\Roaming\npm-cache\_cacache):
Content verified: 33 (5600959 bytes)
Index entries: 48
Finished in 0.176s
If i try to use licence generator with npm init:
C:\Users\almancini\prova>npm init yo license
npx: installed 15 in 2.756s
internal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module 'libnpx'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at resolveFileName (C:\Users\almancini\AppData\Roaming\npm-cache\_npx\7728\node_modules\create-yo\node_modules\resolve-from\index.js:29:39)
at resolveFrom (C:\Users\almancini\AppData\Roaming\npm-cache\_npx\7728\node_modules\create-yo\node_modules\resolve-from\index.js:43:9)
at module.exports (C:\Users\almancini\AppData\Roaming\npm-cache\_npx\7728\node_modules\create-yo\node_modules\resolve-from\index.js:46:47)
at module.exports (C:\Users\almancini\AppData\Roaming\npm-cache\_npx\7728\node_modules\create-yo\node_modules\import-from\index.js:4:55)
at Object.<anonymous> (C:\Users\almancini\AppData\Roaming\npm-cache\_npx\7728\node_modules\create-yo\src\create-yo.js:8:13)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
NodeJS and npm version:
C:\Users\almancini\prova>npm -v
6.9.0
C:\Users\almancini\prova>node -v
v10.16.0
We get the location of libnpx
from global-dirs. Can you please:
-
npm install [email protected]
somewhere - Run
node -e "console.log(require('global-dirs'))"
and paste the output
It's ok, but probably you should specify in documentation that libnpx is required to be installed globally
node -e "console.log(require('global-dirs'))"
{ npm:
{ prefix: 'C:\\Users\\almancini\\AppData\\Roaming\\npm',
packages: 'C:\\Users\\almancini\\AppData\\Roaming\\npm\\node_modules',
binaries: 'C:\\Users\\almancini\\AppData\\Roaming\\npm' },
yarn:
{ prefix: 'C:\\Users\\almancini\\AppData\\Roaming\\npm',
packages:
'C:\\Users\\almancini\\AppData\\Roaming\\npm\\global\\node_modules',
binaries:
'C:\\Users\\almancini\\AppData\\Roaming\\npm\\global\\node_modules\\.bin' } }
If i install libnpx globally i haven't this error anymore.
In any case tool doesn't work because it doesn't found npm path:
C:\Users\almancini\provetta>npm init yo license
npx: installed 15 in 2.289s
ENOENT: no such file or directory, stat 'C:\Users\almancini\AppData\Roaming\npm\npm'
√ create-yo ok!
Have i to install also npm as global package even if i alreay have in my nodejs installation?
EDIT:
I have installed npm as global package, but now i have this error:
C:\Users\almancini\provetta>npm init yo license
npx: installed 15 in 2.256s
Command failed: C:\"Program Files"\nodejs\node.exe "C:\Users\almancini\AppData\Roaming\npm\npm" config get cache --parseable
C:\Users\almancini\AppData\Roaming\npm\npm:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
^^^^^^^
SyntaxError: missing ) after argument list
at Module._compile (internal/modules/cjs/loader.js:721:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:829:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
√ create-yo ok!
there are two problems here:
- I think I'm calling something incorrectly for windows, because that's trying to run a bash script. I'm not sure where exactly that problem is atm
-
libnpx
should be pulled from local dir, if present.
The problem is that on a regular Windows Node.js installation, globalDirs.npm.packages
points to:
C:\Users\dev\AppData\Roaming\npm\node_modules
.
Yet libnpx
is located in the Node.js installation directory at:
C:\Program Files\nodejs\node_modules\npm\node_modules\libnpx
So this line files importFrom(path.join(globalDirs.npm.packages, 'npm'), 'libnpx')
.
Not sure what a clean fix for this looks like.. since global-dirs
is correct in providing the directory for user installed global packages. Tested with globalDirs.npm.binaries
which also points to the user dir C:\Users\dev\AppData\Roaming\npm
.
It just works for me in Windows. I installed Node with choco install nodejs-lts
.
The problem occurs when using the official Node.js Windows installer
Hi All: I found a simple way with zero third-party packages to resolve Linux and Windows libnpx path.
It could be taken a chance to try.
https://github.com/react-atomic/reshow/blob/main/packages/yonpx/src/init.js#L5-L14
it's work for me on node13.