After creating a fresh chroot 'sid' environment
and installing nodejs and npm
`npm install` is throwing the below error:
internal/modules/cjs/loader.js:583
throw err;
^
Error: Cannot find module 'semver'
at Function.Module._resolveFilename
(internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (/usr/share/npm/lib/utils/unsupported.js:2:14)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js
(internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
------------------------------------------------------------
even installed modules are not working while trying to run the below
cmd.
$ ls /usr/share/nodejs/
mixin-deep normalize-path y18n
$ node -e "require('y18n');"
internal/modules/cjs/loader.js:583
throw err;
^
Error: Cannot find module 'y18n'
at Function.Module._resolveFilename
(internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at [eval]:1:1
at Script.runInThisContext (vm.js:96:20)
at Object.runInThisContext (vm.js:303:38)
at Object.<anonymous> ([eval]-wrapper:6:22)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at evalScript (internal/bootstrap/node.js:587:27)
Le dim. 21 juil. 2019 à 20:48, <sgk@riseup.net> a écrit :
Here with same node version
$ node -p "require.resolve('y18n')"
/usr/share/nodejs/y18n/index.js
can you check that last file path exists ?
Then can you compare with your output of:
node -p process.execPath
/usr/bin/node
node -p "require.resolve.paths('y18n')"
[ '/home/dev/node_modules',
'/home/node_modules',
'/node_modules',
'/home/dev/.node_modules',
'/home/dev/.node_libraries',
'/usr/lib/x86_64-linux-gnu/nodejs',
'/usr/share/nodejs',
'/usr/lib/nodejs' ]
Also maybe of interest
node -p process.env.NODE_PATH
Thanks,
Jérémy
I was able to reproduce in a clean sid chroot.
Created chroot with debootstrap, chroot to directory, install nodejs, node-y18n
node -e "require('y18n');" internal/modules/cjs/loader.js:583 throw err; ^ Error: Cannot find module 'y18n'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15) at Function.Module._load (internal/modules/cjs/loader.js:507:25) at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18) at [eval]:1:1 at Script.runInThisContext (vm.js:96:20) at Object.runInThisContext (vm.js:303:38) at Object.<anonymous> ([eval]-wrapper:6:22) at Module._compile (internal/modules/cjs/loader.js:689:30) at evalScript (internal/bootstrap/node.js:587:27)
ls /usr/share/nodejs
y18n
Does this still happen ? Wasn't it a problem with the aforementioned modules ? Jérémy
Hi,
This still occurs for me. I have a armhf chroot of Sid. It seems to be
using a node path relative to the current directory (as far as I can
tell). These paths should probably be /usr prefixed (and not relative to
cwd), but I wouldn't know where to begin fixing this.
See my tests below:
root@sid-armhf:/# node -p "require.resolve.paths('y18n')"
[ '/node_modules',
'/root/.node_modules',
'/root/.node_libraries',
'/lib/arm-linux-gnueabihf/nodejs',
'/share/nodejs',
'/lib/nodejs' ]
root@sid-armhf:/# su user
$ pwd
/
$ node -p "require.resolve.paths('y18n')"
[ '/node_modules',
'/home/user/.node_modules',
'/home/user/.node_libraries',
'/lib/arm-linux-gnueabihf/nodejs',
'/share/nodejs',
'/lib/nodejs' ]
$ cd
$ pwd
/home/user
$ node -p "require.resolve.paths('y18n')"
[ '/home/user/node_modules',
'/home/node_modules',
'/node_modules',
'/home/user/.node_modules',
'/home/user/.node_libraries',
'/home/lib/arm-linux-gnueabihf/nodejs',
'/home/share/nodejs',
'/home/lib/nodejs' ]
$
Le mar. 17 mars 2020 à 14:45, Josh de Kock <josh@itanimul.li> a écrit :
I don't understand how this chroot ends up with those paths either.
How did you set it up ?
I tried a buster armhf chroot:
- nodejs 10.21.0
- npm 5.8.0+ds6-4+deb10u1
a sid ppc64el chroot:
- nodejs 12.18.3
- npm 6.14.6+ds-1
in both cases, i got correct resolve paths, and this works:
node -e "require('y18n');"
Since most of the report talk about node-y18n i suppose it was this module
that was affected during a transition of /usr/lib/nodejs to
/usr/share/nodejs.
To keep things simple i'll leave it here open (without reassigning) for a
while,
unless someone reproduces it again.
Jérémy
reassign 969986 nodejs
merge 969986 932659
thanks
Good catch. I am seeing the same behavior. It looks to me like a
difference in the node module search path, not specific to npm.
If I run `node -e 'console.log(require.resolve.paths("semver"))'` in the
chroot, I get (note the missing /usr prefix):
[
'/node_modules',
'/root/.node_modules',
'/root/.node_libraries',
'/lib/x86_64-linux-gnu/nodejs',
'/share/nodejs',
'/lib/nodejs'
]
In pbuilder I get:
[
'/node_modules',
'/root/.node_modules',
'/root/.node_libraries',
'/usr/lib/x86_64-linux-gnu/nodejs',
'/usr/share/nodejs',
'/usr/lib/nodejs'
]
I think the problem is that process.execPath is "node" in the chroot and
"/usr/bin/node" in pbuilder and that this is used to build the module
search path. The problem occurs when /proc is not mounted.
It appears this was already reported in #932659. Sorry for not noticing
that earlier.
Thanks,
Kevin
Date: Sun, 21 Jul 2019 21:46:17 +0200