简体   繁体   English

运行Protractor时找不到模块'../built/cli.js'

[英]Cannot find module '../built/cli.js' when running Protractor

Because of the present in Protractor 3.3.0 issue with getMultiCapabilities , we have to install Protractor directly from github since the master branch contains the fix which is scheduled for Protractor 3.4. 由于带有getMultiCapabilities Protractor 3.3.0问题 ,我们必须直接从github安装Protractor,因为master分支包含为Protractor 3.4安排的修复

In package.json we've added the following: package.json我们添加了以下内容:

"dependencies": {
  "protractor": "git+https://github.com/angular/protractor.git"
},

And, now, we are getting the following error when trying to run protractor : 而且,现在,我们在尝试运行protractor时遇到以下错误:

> protractor conf.js

module.js:341
    throw err;
    ^

Error: Cannot find module '../built/cli.js'

Is it something we are doing wrong, or Protractor development version cannot be installed and used this way? 这是我们做错了什么,还是Protractor开发版本无法以这种方式安装和使用?

There are differents between package downloading on npm and fetching directly on git repo. npm上下载包和在git repo上直接获取之间有不同之处。

And the main point prevent your protractor to run is: 而要防止量角器运行的要点是:

//protractor from git repo, inside ./bin/protractor
require('../built/cli.js');

//protractor from npm, inside ./bin/protractor
require('../lib/cli.js');

So basically you need to go to protractor local folder then execute gulp task 'prepublish' to setup the environment for protractor . 所以基本上你需要去protractor本地文件夹,然后执行gulp任务'prepublish'来设置protractor的环境。 It will be something like this: 它将是这样的:

// from your project directory
cd node_modules/protractor
// install base dependencies for protractor
npm install
// setup environment by publishing
gulp prepublish

As far as i see, one step is missing. 据我所知,缺少一步。 Protractor has prepublish step in package.json , you can call it manually, or try to do the same as this step do: 量角器在package.json中有preublish步骤,您可以手动调用它,或者尝试执行与此步骤相同的操作:

Error: Cannot find module '../built/cli.js'

What i see in https://github.com/angular/protractor/blob/master/gulpfile.js#L76 : 我在https://github.com/angular/protractor/blob/master/gulpfile.js#L76中看到的内容:

gulp.task('prepublish', function(done) {
  runSequence(['typings', 'jshint', 'format'], 'tsc', 'tsc:globals', 'types',
    'ambient', 'built:copy', done);
});

gulp.task('built:copy', function() {
  return gulp.src(['lib/**/*','!lib/**/*.ts'])
      .pipe(gulp.dest('built/'));
});

I think you just need to do postinstall task, that will copy that files to destination. 我想你只需要做postinstall任务,将文件复制到目的地。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM