Skip to content
This repository has been archived by the owner on Jun 2, 2024. It is now read-only.

使用cnpm安装angular应用的依赖 ,会导致编译失败! #1463

Closed
rdkmaster opened this issue May 19, 2019 · 1 comment
Closed

Comments

@rdkmaster
Copy link

复现此问题的仓库,点击这里,使用npm安装则一切正常,而使用cnpm安装了依赖,虽然安装过程一切正常,但是使用下面这个命令编译:

ng s

则报下面这个错误:

image

经过初步分析后,原因大致如下:

在node_modules目录下,我发现有大量的下划线开头的包:

image

然后,cnpm通过创建与npm同名的软连接,并让他们指向这些下划线开头的包,达到模拟npm安装效果的目的:

image

这个方式对于普通的库,没有问题,但是对于angular这样定义了全局标识符的库,则会导致在编译时,报出最上面那个截图上的错误:

ERROR in node_modules/@angular/core/src/render3/ng_dev_mode.d.ts(9,11): error TS2451: Cannot redeclare block-scoped variable 'ngDevMode'.
node_modules/@rdkmaster/jigsaw/node_modules/@angular/core/src/render3/ng_dev_mode.d.ts(9,11): error TS2451: Cannot redeclare block-scoped variable 'ngDevMode'.

其中,ngDevMode就是一个全局标识符,由于存在两份(一个是软链,一个是下划线开头的包),因此出错。

@rdkmaster rdkmaster changed the title 使用cnpm安装angular应用的依赖 ,回导致编译失败! 使用cnpm安装angular应用的依赖 ,会导致编译失败! May 19, 2019
@killmojo
Copy link

最近也碰到了类似问题,cnpm安装的grapecity的 spread-sheet-vue,运行后总是报错,改用npm就好了。也是发现了很多_@grapecity的文件夹,还有会为依赖在子目录中再创建一个node_modules的文件夹,导致全局的引用不一致。

@fengmk2 fengmk2 closed this as completed Mar 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants