-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
Does not work with npm link #1494
Comments
This is not really a Vue CLI issue. In your project you have specified Put it another way: because your package does not actually have an ESM build, you should not be using |
Hi @yyx990803 thanks for the fast answer. However is does not explain why it works if I install the package over npm. It should throw the same error, but then it works fine. Removing the I also tried it with another package vue-observeable where I used rollup and have different builds. Including a commonjs, esm and umd build.
If this is more webpack 4 related I can move the issue over there. |
|
Simple solutionBuild your npm package project(Let's say A) with
Put this folder under import '/node_modules/dist/xxx.min.js' to import Project A. Then you can test your npm package. WhyThe error message you get is because you are using I guess the reason is that before you import it, Webpack will compile those files under You use When you download it from npm, the files are actually placed under The explanation I came out is based on what I test with my npm package. I am not sure it's correct, but it will work at the end. |
@Haixiang6123 Simple but great idea. |
I solved it with a very simple operation and I hope this message is useful for someone else. |
I got this problem too and config webpack resolve.symlinks to false; then it worked for me;
i think this is the reason |
We want to fall in line with the other examples. The two changes that probably aren't straight-forward are the `vue.config.js` and the `"nohoist"` in the `package.json`. For `vue.config.js`, we need to override the webpack settings for symlinks within this monorepo. Turns out there's a known issue with webpack and symlinks: https://webpack.js.org/configuration/resolve/#resolvesymlinks. There's a workaround for Vue we can use: vuejs/vue-cli#1494 (comment). So, we use it. This allows us to reference the local version of the SDK and use it. This also means we can be consistent with the other examples. For `"nohoist"`, we ran into another conflict with the dependencies being hoisted to the top-level, but it seemed impossible to fix by just being more specific in the workspaces. The backstory here is that we've consistently run into this issue before where some dependency is hoisted to the top-level and `react-scripts` blows up because it's not the version it was expecting. For the most part, we end up keeping similar dependencies in each different package. Because they all use different versions, none of them are hoisted. But now, there's multiple dependencies in the `datadog-app-example-vue-custom-widget` package that depend on the same version of `webpack`. Since multiple dependencies depend on the same version, yarn decides to hoist it to the top-level, which causes `react-scripts` to explode. We work around that by using the `"nohoist"` option: https://classic.yarnpkg.com/blog/2018/02/15/nohoist/. We probably should've used this from the start, but here we are. Hopefully, this will make these sorts of issues less prevalent in the future. The rest of these changes are just making things consistent (read: pass CI).
Seems still a thing in 2024 - For Vite users adding this in vite.config.ts worked for me |
Version
3.0.0-beta.15
Reproduction link
https://github.com/apertureless/vue-breakpoints
Steps to reproduce
vue create
npm install & npm run build && npm run link
inside thevue-breakpoints
reponpm link vue-breakpoints
What is expected?
That locally linked npm packeges are working.
What is actually happening?
It throws an error:
Before that it also throws some errors regarding missing eslint packages that are installed in the vue-breakpoints repo but somehow the dependencies are not found.
In packages without named exports it throws
The output in vue-breakpoints is a umd module and should work everywhere. This also only happens with local linked packages. If I install it over npm it works fine. However I am often using
npm link
to test new pacakges or versions before releasing to npm.This happens with various packages not only
vue-breakpoints
And this only happens with projects created with
vue create
. The oldvue init webpack
projects are not affected by this. And the linking works fine.If you need any more info, let me know ✌️
The text was updated successfully, but these errors were encountered: