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

Installed module cannot access it's dependencies with node v17.4.0 #4364

Closed
axmad386 opened this issue Feb 21, 2022 · 8 comments
Closed

Installed module cannot access it's dependencies with node v17.4.0 #4364

axmad386 opened this issue Feb 21, 2022 · 8 comments

Comments

@axmad386
Copy link

pnpm version: 6.3.1

Code to reproduce the issue:

npx degit kodepandai/lunox lunoxapp
cd lunoxapp
pnpm install
pnpm build
pnpm serve

Expected behavior:

Lunox app should run successfully
This is when I run pnpm serve with node v16.6.2

❯ pnpm serve

> lunox-app@0.8.0 serve /home/dmuggle/GIT/cobalunox
> lunox serve

serving application...
server run on port: 8000

Actual behavior:

lunox dependencies is not detected by pnpm, for example @kodepandai/flydrive, sirv, etc.
This is console.log when I run pnpm serve

❯ pnpm serve

> lunox-app@0.8.0 serve /home/dmuggle/GIT/cobalunox
> lunox serve

serving application...
node:internal/process/esm_loader:94
    internalBinding('errors').triggerUncaughtException(
                              ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@kodepandai/flydrive' imported from /home/dmuggle/GIT/cobalunox/node_modules/lunox/dist/index.js
Did you mean to import @kodepandai+flydrive@2.0.0/node_modules/@kodepandai/flydrive/build/index.js?
    at new NodeError (node:internal/errors:371:5)
    at packageResolve (node:internal/modules/esm/resolve:892:9)
    at moduleResolve (node:internal/modules/esm/resolve:938:18)
    at defaultResolve (node:internal/modules/esm/resolve:1041:11)
    at ESMLoader.resolve (node:internal/modules/esm/loader:530:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:251:18)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:79:40)
    at link (node:internal/modules/esm/module_job:78:36) {
  code: 'ERR_MODULE_NOT_FOUND'
}

Node.js v17.4.0

Additional information:

  • node -v prints: v17.4.0
  • Windows, macOS, or Linux?: Linux
@BlackHole1
Copy link
Member

Works fine with node@v16.13.2. The problem arises when using node@v17.4.0.

cc: @zkochan

@BlackHole1
Copy link
Member

update: node@v17.0.1 works fine, fails from node@17.1.0

@BlackHole1
Copy link
Member

It is possible that the problem was introduced by nodejs/node#40510.

I personally feel that you should submit relevant issues to nodejs

@BlackHole1
Copy link
Member

@axmad386
Copy link
Author

@BlackHole1 thanks for information. So what should I do for now? I must downgrade the nodejs version?

@BlackHole1
Copy link
Member

  1. downgrade nodejs version, waiting nodejs fix.
  2. v17.1.0 node resolution breaks pnpm-style symlinks nodejs/node#41087 (comment)
  3. v17.1.0 node resolution breaks pnpm-style symlinks nodejs/node#41087 (comment)

@axmad386
Copy link
Author

ok, thank you so much

@axmad386
Copy link
Author

axmad386 commented Mar 8, 2022

Hi, just want to clarify. I was able to solve this issue by implementing explicit import.
Just change

import module from './folder/module'

to

import module from './folder/module.js'

Note that we must use .js extension even we are using typescript.
I will close this issue, thank you

@axmad386 axmad386 closed this as completed Mar 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants