我開始創建一個本地原因單元測試庫,由RSpec的啓發(我做了一個F#以前)創建理由封裝,具有不同的命名空間名稱與NPM包
我想調用庫Respect
,但由於已經有一個名爲「尊重」的npm包,我將npm庫命名爲「重新尊重」。但我bsconfig.json
指定我推了包,並從一個測試項目,在這裏我引用Respect
命名空間導入它作爲respect
{
"name": "Respect",
"version": "0.1.0",
"namespace": true,
"sources": [
{"dir": "src"},
{
"dir": "tests",
"type": "dev"
}
],
"bs-dependencies" : [
// add your bs-dependencies here
]
}
包的名稱。我在這個項目這個原因源文件:
open Respect.Dsl;
describe "Foo" [
it "has a test" (fun _ =>())
] |> register;
!rootContext |> run;
與npm run build
正常工作構建代碼,但是當我運行測試,我得到的錯誤:
module.js:529
throw err;
^
Error: Cannot find module 'Respect/lib/js/src/dsl.js'
at Function.Module._resolveFilename (module.js:527:15)
...
的錯誤是明確的 - npm包安裝在node_modules/re-respect
而不是node_modules/Respect
,它試圖找到代碼。
我在做我不應該做的事嗎?我的根名稱空間應該遵循NPM包名嗎?我需要找到一個新的名字嗎?
p.s.在寫這篇文章的時候,我意識到package.json和bsconfig.json之間的版本號是有區別的 - 但我懷疑這是問題的根源。