模板启动错误 – types错误(“参数”url“必须是一个string,而不是”+ typeofurl)

我已经使用了一段时间的模具,并正在开发一个自定义的主题,我已经安装nvm和节点5.0和npm 2.我也删除了模具,并做了全新的安装包括节点模块和模具初始化但不pipe什么时候运行模具启动我仍然得到下面的错误,我已经google了,并已空了,所以我希望有人可以帮助我。 提前致谢!

⇒ stencil start url.js:110 throw new TypeError("Parameter 'url' must be a string, not " + typeof url) ^ TypeError: Parameter 'url' must be a string, not undefined at Url.parse (url.js:110:11) at Object.urlParse [as parse] (url.js:104:5) at module.exports (/usr/local/lib/node_modules/@bigcommerce/stencil-cli/server/index.js:14:31) at startServer (/usr/local/lib/node_modules/@bigcommerce/stencil-cli/bin/stencil-start:188:5) at /usr/local/lib/node_modules/@bigcommerce/stencil-cli/bin/stencil-start:166:32 at /usr/local/lib/node_modules/@bigcommerce/stencil-cli/server/lib/stencil-token.js:55:24 at finish (/usr/local/lib/node_modules/@bigcommerce/stencil-cli/node_modules/wreck/lib/index.js:137:20) at wrapped (/usr/local/lib/node_modules/@bigcommerce/stencil-cli/node_modules/hoek/lib/index.js:866:20) at ClientRequest.onResponse (/usr/local/lib/node_modules/@bigcommerce/stencil-cli/node_modules/wreck/lib/index.js:158:20) at ClientRequest.g (events.js:199:16) 

我从来没有使用过Stencil,但是这个错误正在抛出,因为这个URL没有在你的模板configuration文件( ./.stencil )中设置。 这是否应该在stencil init期间设置?

具体来说,你需要确保在.stencil文件中设置了这两个值(我假设它是位于项目根目录下的JSONconfiguration文件):

  1. storeUrl ————– //到安全页面的URL(提示为login页面)
  2. normalStoreUrl//主页的主机url

知道如何debugging节点错误可能是有用的。 以下是我的思考过程如何进行阅读和debugging:

1。

 TypeError: Parameter 'url' must be a string, not undefined at Url.parse (url.js:110:11) at Object.urlParse [as parse] (url.js:104:5) 

所以这个错误非常简单。 该程序试图从stringparsingURL,但该string是未定义的,从而导致主要的错误。 具体来说,节点模块url.js正在尝试执行parsing。

应该在哪里定义URL? 让我们继续看看我们能否弄清楚。

2:

 at module.exports (/usr/local/lib/node_modules/@bigcommerce/stencil-cli/server/index.js:14:31) 

https://github.com/bigcommerce/stencil-cli/blob/master/server/index.js
好的,让我们打开这个文件,看第14行,内容如下:

 module.exports = function(options, callback) { var config = manifest.get('/'), parsedSecureUrl = Url.parse(options.dotStencilFile.storeUrl), //Line 14 - The url to a secure page (prompted as login page) parsedNormalUrl = Url.parse(options.dotStencilFile.normalStoreUrl); //The host url of the homepage; ... 

好的,所以我们find了引发错误的确切位置( parsedSecureUrl )。 这个URL应该包含在用来初始化这个模块的选项对象中( module.exports = function(options, callback) {}

需要继续挖掘以查看该选项对象的定义位置,以及如何包括其dotStencilFile属性( options.dotStencilFile )。

3:

 at startServer (/usr/local/lib/node_modules/@bigcommerce/stencil-cli/bin/stencil-start:188:5) 

https://github.com/bigcommerce/stencil-cli/blob/master/bin/stencil-start其中的内容如下:

  /** * Starts up the local Stencil Server as well as starts up BrowserSync and sets some watch options. */ function startServer() { var params = { dotStencilFile: dotStencilFile, //It's getting set here!! variationIndex: themeConfig.variationIndex || 0, stencilEditorEnabled: Program.themeEditor, stencilEditorPort: Program.themeEditorPort || 8181, useCache: Program.cache }; //Line 188 below: Server(params, function (err) { var watchFiles = [ '/assets', '/templates', '/lang' ]; ... 

所以我们在第二步find了负责初始化和传递options参数给模块的函数。具体来说,这个variables被称为params ,应该包含这个URL的对象是params.dotStencilFile

在这一点上,我们只需要弄清楚dotStencilFile应该是什么。

4:

通过在这个文件中的源代码search,我可以看到dotStencilFile声明: dotStencilFile = Fs.readFileSync(dotStencilFilePath, {encoding: 'utf-8'});
所以dotStencilFile的值是通过从位于dotStencilFilePath磁盘读取一个文件来设置的。

最后一个问题是什么呢? … dotStencilFilePath的价值是dotStencilFilePath

对我们来说很容易,它的价值是在这个相同的文件中定义的:
var dotStencilFilePath = Path.join(themePath, '.stencil');
where themePath = var themePath = process.cwd(); (这个文件的当前工作目录,假设是项目的根目录)。

5 :(解决scheme)
好吧,我们知道了! 应该包含URL的文件称为.stencil (隐藏文件),它位于项目根目录( /Users/rob/myStencilProject/.stencil )中。

这个.stencil文件应该是一个包含两个URL属性值的JSON文件: storeUrlnormalStoreUrl

我应该检查这个文件,以确保这些属性已经设置。 我是否应该在stencil init设置它们? 我可以手动设置它们吗? 无论哪种方式,我敢肯定,主要的错误是由于这个文件不包含上述两个URL的值。



Welp,我希望这些信息有助于解决当前的问题,以及在开发过程中遇到的其他问题。 祝你好运!

我已经解决了这个问题。 该url应该由Stencil init上的模板设置,然后在Stencil上启动它匹配它们。 事实certificate,我并不知道客户的账户已经变得不活跃,这意味着它不再存在。 简而言之,这个URL没有被定义,因为没有url被定义,而是客户端不再有一个设置。