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

import { message } from "ant-design-vue" fails, since v1.2.0 #37

Closed
lilkui opened this issue Aug 27, 2021 · 6 comments
Closed

import { message } from "ant-design-vue" fails, since v1.2.0 #37

lilkui opened this issue Aug 27, 2021 · 6 comments

Comments

@lilkui
Copy link

lilkui commented Aug 27, 2021

[vite] Internal server error: Failed to resolve import "xxx/node_modules/.pnpm/registry.nlark.com+/ant-design-vue/es/message/style/index" from "xxx". Does the file exist?

This error doesn't occur with v1.1.1

@dr2009
Copy link

dr2009 commented Aug 29, 2021

same as you

pnpm not work
npm is ok

@dr2009
Copy link

dr2009 commented Aug 29, 2021

1.1.1

export function resolveNodeModules(root: string, ...dir: string[]) {
  return normalizePath(path.join(root, 'node_modules', ...dir));
}

1.2.0+

export function resolveNodeModules(libName: string, ...dir: string[]) {
  const modulePath = require.resolve(libName)
  const lastIndex = modulePath.indexOf(libName)

  return normalizePath(path.resolve(modulePath.substring(0, lastIndex), ...dir))
}

@Ludidi
Copy link

Ludidi commented Sep 6, 2021

pnpm:

{
    libraryName: 'ant-design-vue',
    esModule: true,
    resolveStyle: (name) => {
      return `../ant-design-vue/es/${name}/style/index`
    },
},

@lilkui
Copy link
Author

lilkui commented Sep 6, 2021

For me, it has to be configured as following to work properly with pnpm:

{
  libraryName: "ant-design-vue",
  esModule: true,
  esolveStyle: (name) => {
    return `../../ant-design-vue/es/${name}/style/index`;
  },
},

@franxois
Copy link

I have a similar issue in this branch of one of my repo https://github.com/franxois/vite-react-antd-storybook/tree/issue-with-style-import

The project have "antd" in the name, I clone it in a folder with "antd" in the name and I get the error

14:45:56 [vite] Internal server error: Failed to resolve import "/Users/Francois/Documents/dev/github.com/franxois/vite-react-/antd/es/button/style/index" from "src/App.tsx". Does the file exist?

I think the string replace catch the main folder name instead of the one in node_modules. In my case I can fix the issue by replacing ...antd... by ...anttd... in my projetc folder name

@anncwb
Copy link
Collaborator

anncwb commented Nov 25, 2021

fix 1.4.0

@anncwb anncwb closed this as completed Nov 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants