【发布时间】:2019-10-04 19:17:50
【问题描述】:
我有一个应用程序,我试图在其中使用 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(原始与分叉)时,我注意到可用文件和文件夹存在许多差异。
我意识到我应该在更新软件包之前提交初始回滚。这将使提交在调查中更有价值。 但是,此时我必须转移到另一个项目,并且暂时无法尝试。
我遵循的步骤:
- 通过 GitHub 分叉 Angular-CLI。
- 将 head 重置为上次 1.7.4 提交 (
git reset --hard 0b291ab)。 - 使用 npm(
less和node-sass)更新分叉包中的必要包。 - 运行 Yarn 命令(
yarn后跟yarn link),详见此处:https://github.com/angular/angular-cli - 发布到 npm (
npm publish)。 - 将 npm 包安装到 Angular 4 应用程序中(我尝试通过
npm install angularcli-patched-cryptiles和 GitHub 通过npm install applegater/angular-cli使用 NPM 作为安装源,但每个都有相同的结果)
如何使用 NPM 发布我的 fork 以在 Angular 4 应用程序中使用?我应该放弃yarn 命令吗?
运行npm install时出现Yarn错误:
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
分叉回购:https://github.com/applegater/angular-cli
NPM:https://www.npmjs.com/package/angularcli-patched-cryptiles
【问题讨论】:
-
您是否尝试过在您的 Angular 项目中使用 yarn 安装依赖项?
标签: angular npm angular-cli fork yarnpkg