Skip to content

npm packages using local paths are not supported. #107

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

Closed
michalczaplinski opened this issue May 27, 2021 · 3 comments
Closed

npm packages using local paths are not supported. #107

michalczaplinski opened this issue May 27, 2021 · 3 comments
Labels
enhancement New feature or request tracked

Comments

@michalczaplinski
Copy link

Describe the bug:

The runtime does not support local npm packages using the "packageName": "file:./package" syntax.

Link to the blitz that caused the error:

https://stackblitz.com/edit/node-5ppqi3

Steps to reproduce:

npm install 
node index.js
Error: Cannot find module '/projects/node-5ppqi3/node_modules/test-package/index.js'. Please verify that the package.json has a valid "main" entry
    at tryPackage (https://node-5ppqi3.jw.staticblitz.com/blitz.57be275669708b1d42e233d60c80159bef577631.js:6:178912)
    at Function.Module._findPath (https://node-5ppqi3.jw.staticblitz.com/blitz.57be275669708b1d42e233d60c80159bef577631.js:6:180576)
    at Function.Module._resolveFilename (https://node-5ppqi3.jw.staticblitz.com/blitz.57be275669708b1d42e233d60c80159bef577631.js:6:185323)
    at Function.Module._load (https://node-5ppqi3.jw.staticblitz.com/blitz.57be275669708b1d42e233d60c80159bef577631.js:6:183130)
    at Module.require (https://node-5ppqi3.jw.staticblitz.com/blitz.57be275669708b1d42e233d60c80159bef577631.js:6:186304)
    at i (https://node-5ppqi3.jw.staticblitz.com/blitz.57be275669708b1d42e233d60c80159bef577631.js:6:484674)
    at _0x1cc684 (https://node-5ppqi3.jw.staticblitz.com/blitz.57be275669708b1d42e233d60c80159bef577631.js:11:20414)
    at Object.eval (/projects/node-5ppqi3/index.js:2:14)
    at Object.function (https://node-5ppqi3.jw.staticblitz.com/blitz.57be275669708b1d42e233d60c80159bef577631.js:11:20499)
    at Module._compile (https://node-5ppqi3.jw.staticblitz.com/blitz.57be275669708b1d42e233d60c80159bef577631.js:6:187549) {
  code: 'MODULE_NOT_FOUND',
  path: '/projects/node-5ppqi3/node_modules/test-package/package.json',
  requestPath: 'test-package'
}

Expected behavior:

Should run successfully

Desktop (please complete the following information):

  • OS: MacOS
  • Browser: chrome
  • Version: 90
@KwintenP
Copy link
Contributor

Hey!

You are right. This syntax is indeed not supported at this point. We do have this on our roadmap but might not be implemented in the near future. I will add this to our internal issue tracker so we def keep tracking it!

@KwintenP KwintenP added enhancement New feature or request tracked labels May 27, 2021
@luisherranz
Copy link

luisherranz commented May 28, 2021

Until this is fixed, a possible workaround is to use workspaces.

For example, if your local dependencies are in the packages folder, like this:

{
  "dependencies": {
    "my-package": "file:./packages/my-package"
  }
}

You can make StackBlitz install them correctly by adding:

{
  "workspaces": [
    "packages/*"
  ]
}

With a small caveat: it doesn't work if you only have local dependencies. You need to have at least one external dependency:

{
  "dependencies": {
    "my-package": "file:./packages/my-package",
    "dependency": "0.0.1"
  }
}

Also, you probably need to remove both node_modules and package-lock.json before running npm install again.

This is the example that @michalczaplinski shared, but working now: https://stackblitz.com/edit/local-packages-node-example

@d3lm
Copy link

d3lm commented Jan 5, 2023

This issue has been fixed.

@d3lm d3lm closed this as completed Jan 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request tracked
Projects
None yet
Development

No branches or pull requests

4 participants