在NPM的Angular 4应用程序中使用分叉的Angular-CLI

时间:2019-05-17 12:46:18

标签: angular npm angular-cli fork yarnpkg

我有一个应用程序,试图在其中使用Angular CLI 1.7.4(https://github.com/angular/angular-cli/releases/tag/v1.7.4)的分支版本。我已经进行了分叉和修改,但是现在我正在努力在Angular 4应用程序中利用此程序包。

问题是使用NPM安装软件包时,出现Yarn错误Please use Yarn instead of NPM to install dependencies.。当我比较NPM的原始tarball(原始vs分支)时,我注意到可用文件和文件夹有很多差异。

我知道在更新软件包之前,我应该已经进行了初始回滚。这将使这些提交在调查中更有价值。  但是,在这一点上,我必须转到另一个项目,并且一段时间后将无法尝试。

我遵循的步骤:

  1. 通过GitHub叉Angular-CLI。
  2. 将头重置为上一次提交1.7.4(git reset --hard 0b291ab)。
  3. 使用npm(lessnode-sass)更新分叉包中的必要包。
  4. 运行Yarn命令(yarn后跟yarn link),如下所示:https://github.com/angular/angular-cli
  5. 发布到npm(npm publish)。
  6. 将npm软件包安装到Angular 4应用程序中(我曾尝试通过npm install angularcli-patched-cryptiles使用NPM,并通过npm install applegater/angular-cli使用GitHub作为安装源,但每个结果都相同)

如何使用NPM发布供在Angular 4应用程序中使用的fork?我应该放弃yarn命令吗?

运行npm install时出现纱线错误:

PS C:\SourceCode\patchedapp> npm install applegater/angular-cli
npm WARN deprecated browserslist@2.11.3: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.

> angularcli-patched-cryptiles@1.7.5 preinstall C:\SourceCode\patchedapp\node_modules\angularcli-patched-cryptiles
> node ./tools/yarn/check-yarn.js

C:\SourceCode\patchedapp\node_modules\angularcli-patched-cryptiles\tools\yarn\check-yarn.js:12
  throw new Error(
  ^

Error: Please use Yarn instead of NPM to install dependencies. See: https://yarnpkg.com/lang/en/docs/install/
    at Object.<anonymous> (C:\SourceCode\patchedapp\node_modules\angularcli-patched-cryptiles\tools\yarn\check-yarn.js:12:9)
    at Module._compile (internal/modules/cjs/loader.js:701:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    at Module.load (internal/modules/cjs/loader.js:600:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
    at Function.Module._load (internal/modules/cjs/loader.js:531:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
npm WARN rollback Rolling back source-map@0.4.4 failed (this is probably harmless): EPERM: operation not permitted, scandir 'C:\SourceCode\patchedapp\node_modules\scss-tokenizer\node_modules'
npm WARN rollback Rolling back faye-websocket@0.11.1 failed (this is probably harmless): EPERM: operation not permitted, lstat 'C:\SourceCode\patchedapp\node_modules\sockjs-client\node_modules'npm WARN @ngrx/effects@2.0.2 requires a peer of @angular/core@^2.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @ngrx/store@2.2.1 requires a peer of @angular/core@^2.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN codelyzer@2.1.1 requires a peer of tslint@^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN ng2-charts@1.5.0 requires a peer of @angular/common@^2.3.0 but none is installed. You must install peer dependencies yourself.
npm WARN ng2-charts@1.5.0 requires a peer of @angular/core@^2.3.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! angularcli-patched-cryptiles@1.7.5 preinstall: `node ./tools/yarn/check-yarn.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the angularcli-patched-cryptiles@1.7.5 preinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\<username>\AppData\Roaming\npm-cache\_logs\2019-05-17T12_27_02_933Z-debug.log

原始(左)和叉形(右)npm tarball之间的差异。 enter image description here

叉式回购:https://github.com/applegater/angular-cli

NPM:https://www.npmjs.com/package/angularcli-patched-cryptiles

1 个答案:

答案 0 :(得分:0)

我知道了! Angular CLI 7从npm更改为yarn。为了解决与初始回滚的冲突,git从Angular CLI 7中引入了一些额外的yarn文件。为解决此问题,我创建了一个新的存储库(不是基于cli的分支)并提交了1.7.4版本那里的cli。现在安装!