3

我正在尝试按照 构建步骤中的描述构建https://github.com/angular/angular master 。当我 gulp build.js 时,我最终得到了这个错误:

gulp build.js
Dart SDK detected
[20:10:31] Using gulpfile ~/dvl/mongo/angular2/gulpfile.js
[20:10:31] Starting 'build/clean.js'...
[20:10:31] Starting 'build/clean.tools'...
[20:10:31] Finished 'build/clean.tools' after 1.34 ms
[20:10:31] Starting 'build.tools'...
[20:10:31] Starting '!build.tools'...
[20:10:31] Finished 'build/clean.js' after 174 ms
[20:10:31] Starting 'build.js.dev'...
[20:10:31] Starting 'build/clean.tools'...
[20:10:31] Finished 'build/clean.tools' after 853 μs
tools/broccoli/angular_builder.ts(1,16): error TS2304: Cannot find name 'require'.
[20:10:33] '!build.tools' errored after 1.82 s
[20:10:33] TypeScript error: tools/broccoli/angular_builder.ts(1,16): error TS2304: Cannot find name 'require'.
    at Output.getError (/home/me/dvl/mongo/angular2/node_modules/gulp-typescript/release/output.js:191:19)
    at Output.diagnostic (/home/me/dvl/mongo/angular2/node_modules/gulp-typescript/release/output.js:238:25)
    at ProjectCompiler.inputDone (/home/me/dvl/mongo/angular2/node_modules/gulp-typescript/release/compiler.js:60:33)
    at CompileStream.end (/home/me/dvl/mongo/angular2/node_modules/gulp-typescript/release/main.js:52:31)
    at DestroyableTransform.onend (/home/me/dvl/mongo/angular2/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:523:10)
    at DestroyableTransform.g (events.js:199:16)
    at DestroyableTransform.emit (events.js:129:20)
    at /home/me/dvl/mongo/angular2/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:965:16
    at process._tickCallback (node.js:355:11)
[20:10:33] 'build.tools' errored after 1.82 s
[20:10:33] Error: [object Object]
    at formatError (/opt/npm-global/lib/node_modules/gulp/bin/gulp.js:169:10)
    at Gulp.<anonymous> (/opt/npm-global/lib/node_modules/gulp/bin/gulp.js:195:15)
    at Gulp.emit (events.js:129:20)
    at Gulp.Orchestrator._emitTaskDone (/home/me/dvl/mongo/angular2/node_modules/gulp/node_modules/orchestrator/index.js:264:8)
    at /home/me/dvl/mongo/angular2/node_modules/gulp/node_modules/orchestrator/index.js:275:23
    at finish (/home/me/dvl/mongo/angular2/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:21:8)
    at cb (/home/me/dvl/mongo/angular2/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:29:3)
    at finish (/home/me/dvl/mongo/angular2/node_modules/run-sequence/index.js:53:5)
    at Gulp.onError (/home/me/dvl/mongo/angular2/node_modules/run-sequence/index.js:60:4)
    at Gulp.emit (events.js:129:20)
[20:10:33] 'build.js.dev' errored after 1.65 s
[20:10:33] Error: [object Object]
    at formatError (/opt/npm-global/lib/node_modules/gulp/bin/gulp.js:169:10)
    at Gulp.<anonymous> (/opt/npm-global/lib/node_modules/gulp/bin/gulp.js:195:15)
    at Gulp.emit (events.js:129:20)
    at Gulp.Orchestrator._emitTaskDone (/home/me/dvl/mongo/angular2/node_modules/gulp/node_modules/orchestrator/index.js:264:8)
    at /home/me/dvl/mongo/angular2/node_modules/gulp/node_modules/orchestrator/index.js:275:23
    at finish (/home/me/dvl/mongo/angular2/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:21:8)
    at cb (/home/me/dvl/mongo/angular2/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:29:3)
    at finish (/home/me/dvl/mongo/angular2/node_modules/run-sequence/index.js:53:5)
    at Gulp.onError (/home/me/dvl/mongo/angular2/node_modules/run-sequence/index.js:60:4)
    at Gulp.emit (events.js:129:20)
[20:10:33] 'build.js.dev' errored after 1.65 s
[20:10:33] Error: [object Object]
    at formatError (/opt/npm-global/lib/node_modules/gulp/bin/gulp.js:169:10)
    at Gulp.<anonymous> (/opt/npm-global/lib/node_modules/gulp/bin/gulp.js:195:15)
    at Gulp.emit (events.js:129:20)
    at Gulp.Orchestrator._emitTaskDone (/home/me/dvl/mongo/angular2/node_modules/gulp/node_modules/orchestrator/index.js:264:8)
    at /home/me/dvl/mongo/angular2/node_modules/gulp/node_modules/orchestrator/index.js:275:23
    at finish (/home/me/dvl/mongo/angular2/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:21:8)
    at cb (/home/me/dvl/mongo/angular2/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:29:3)
    at finish (/home/me/dvl/mongo/angular2/node_modules/run-sequence/index.js:53:5)
    at Gulp.onError (/home/me/dvl/mongo/angular2/node_modules/run-sequence/index.js:60:4)
    at Gulp.emit (events.js:129:20)
tools/broccoli/angular_builder.ts(2,11): error TS2304: Cannot find name 'require'.
tools/broccoli/angular_builder.ts(3,23): error TS2304: Cannot find name 'require'.
tools/broccoli/angular_builder.ts(4,20): error TS2304: Cannot find name 'require'.
tools/broccoli/angular_builder.ts(5,20): error TS2304: Cannot find name 'require'.
tools/broccoli/angular_builder.ts(6,12): error TS2304: Cannot find name 'require'.
tools/broccoli/angular_builder.ts(7,22): error TS2304: Cannot find name 'require'.

我没有安装量角器和 Chrome Canary,但我认为它们无关。至少几周前,没有它们,它的建设还不错。

我还尝试在这里和那里将 require('typescript-require');( https://github.com/eknkc/typescript-require ) 放入 gulpfile 但没有任何成功。

因此,我们非常感谢您的帮助。

4

2 回答 2

2

感谢@s.Daniel 的帮助,我总结了我在 win 机器上构建 angular2 的所有努力:

1. 安装 bower 依赖从 root 运行bower install 如果你会看到这样的错误, bower angular#1.0.6 ENOGIT git is not installed or not in the PATH那么你需要像这样指定环境变量 Path:

set PATH=%PATH%;C:\Program Files\Git\bin

将路径替换为您的文件夹路径git.exe

2. 从您的本地仓库转到文件夹 angular\tools 并从那里运行这些命令: 为了安装工具的依赖项,

npm install
tsd install

如果没有此命令,您应该会看到如下错误:

error TS2304: Cannot find name 'promise' or error TS2304: Cannot find name 'require' or whatever it looking for.

3. 从本地 repo 根目录转到文件夹angular\modules\angular2并运行与步骤 2 相同的命令。

npm install
tsd install

如果不运行此命令,则会出现以下错误:错误:

[DiffingTSCompiler]: Typescript found the following errors: 
angular2/manual_typings/globals.d.ts (8, 42): Cannot find name 'Promise'

.

此处:在 win 10 上构建 angular 2 beta 7

于 2016-03-07T00:53:38.543 回答
2

对我来说,这个错误的修复是手动安装类型定义:

cd tools 
tsd install
于 2016-01-25T16:37:03.890 回答