Bit: packageNameToComponentId unable to determine the id of api, it has no dot and is not exists on .bitmap

Created on 2 Jul 2020  Â·  5Comments  Â·  Source: teambit/bit

Describe the bug

As explained in #2789
The last released (v14.8.4) didn't fixed the issue.

Steps to Reproduce

A few differences noticed with the new released.

After added the component and its dependencies, I had to link --rewire to fix error in status. I don't have anymore.
````
$ bit status
new components
(use "bit tag --all [version]" to lock a version with all your changes)

 > api ... ok
 > authentication-service ... ok
 > email-service ... ok
 > store ... ok
 > welcome ... ok

`````

But when I try to build, I have this error :
````
Unhandled rejection Error: no such file or directory
at MemoryFileSystem.readdirSync (/Users/sarahgoldfarb/Development/Node/dps-demo/client/.git/bit/components/bundlers/vue/bit.envs/2.6.21/node_modules/memory-fs/lib/MemoryFileSystem.js:126:10)
at /Users/sarahgoldfarb/Development/Node/dps-demo/client/.git/bit/components/bundlers/vue/bit.envs/2.6.21/dist/vue-bundler/index.js:25:16
at finalCallback (/Users/sarahgoldfarb/Development/Node/dps-demo/client/.git/bit/components/bundlers/vue/bit.envs/2.6.21/node_modules/webpack/lib/Compiler.js:257:39)
at /Users/sarahgoldfarb/Development/Node/dps-demo/client/.git/bit/components/bundlers/vue/bit.envs/2.6.21/node_modules/webpack/lib/Compiler.js:273:13
at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/sarahgoldfarb/Development/Node/dps-demo/client/.git/bit/components/bundlers/vue/bit.envs/2.6.21/node_modules/tapable/lib/HookCodeFactory.js:33:10), :6:1)
at AsyncSeriesHook.lazyCompileHook (/Users/sarahgoldfarb/Development/Node/dps-demo/client/.git/bit/components/bundlers/vue/bit.envs/2.6.21/node_modules/tapable/lib/Hook.js:154:20)
at onCompiled (/Users/sarahgoldfarb/Development/Node/dps-demo/client/.git/bit/components/bundlers/vue/bit.envs/2.6.21/node_modules/webpack/lib/Compiler.js:271:21)
at /Users/sarahgoldfarb/Development/Node/dps-demo/client/.git/bit/components/bundlers/vue/bit.envs/2.6.21/node_modules/webpack/lib/Compiler.js:671:15
at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/sarahgoldfarb/Development/Node/dps-demo/client/.git/bit/components/bundlers/vue/bit.envs/2.6.21/node_modules/tapable/lib/HookCodeFactory.js:33:10), :6:1)
at AsyncSeriesHook.lazyCompileHook (/Users/sarahgoldfarb/Development/Node/dps-demo/client/.git/bit/components/bundlers/vue/bit.envs/2.6.21/node_modules/tapable/lib/Hook.js:154:20)
at /Users/sarahgoldfarb/Development/Node/dps-demo/client/.git/bit/components/bundlers/vue/bit.envs/2.6.21/node_modules/webpack/lib/Compiler.js:668:31
at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/sarahgoldfarb/Development/Node/dps-demo/client/.git/bit/components/bundlers/vue/bit.envs/2.6.21/node_modules/tapable/lib/HookCodeFactory.js:33:10), :6:1)
at AsyncSeriesHook.lazyCompileHook (/Users/sarahgoldfarb/Development/Node/dps-demo/client/.git/bit/components/bundlers/vue/bit.envs/2.6.21/node_modules/tapable/lib/Hook.js:154:20)
at /Users/sarahgoldfarb/Development/Node/dps-demo/client/.git/bit/components/bundlers/vue/bit.envs/2.6.21/node_modules/webpack/lib/Compilation.js:1385:35
at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/sarahgoldfarb/Development/Node/dps-demo/client/.git/bit/components/bundlers/vue/bit.envs/2.6.21/node_modules/tapable/lib/HookCodeFactory.js:33:10), :6:1)
at AsyncSeriesHook.lazyCompileHook (/Users/sarahgoldfarb/Development/Node/dps-demo/client/.git/bit/components/bundlers/vue/bit.envs/2.6.21/node_modules/tapable/lib/Hook.js:154:20)
at /Users/sarahgoldfarb/Development/Node/dps-demo/client/.git/bit/components/bundlers/vue/bit.envs/2.6.21/node_modules/webpack/lib/Compilation.js:1376:32
at eval (eval at create (/Users/sarahgoldfarb/Development/Node/dps-demo/client/.git/bit/components/bundlers/vue/bit.envs/2.6.21/node_modules/tapable/lib/HookCodeFactory.js:33:10), :11:1)
at /Users/sarahgoldfarb/Development/Node/dps-demo/client/.git/bit/components/bundlers/vue/bit.envs/2.6.21/node_modules/terser-webpack-plugin/dist/index.js:321:9
at step (/Users/sarahgoldfarb/Development/Node/dps-demo/client/.git/bit/components/bundlers/vue/bit.envs/2.6.21/node_modules/terser-webpack-plugin/dist/TaskRunner.js:87:9)
at /Users/sarahgoldfarb/Development/Node/dps-demo/client/.git/bit/components/bundlers/vue/bit.envs/2.6.21/node_modules/terser-webpack-plugin/dist/TaskRunner.js:111:15
at tryCatcher (/Users/sarahgoldfarb/Development/Node/dps-demo/client/.git/bit/components/bundlers/vue/bit.envs/2.6.21/node_modules/bluebird/js/release/util.js:16:23)

Module not found: Error: Can't resolve '@/store.js' in '/Users/sarahgoldfarb/Development/Node/dps-demo/client/src/services'
````

I tried to link --rewire and build again and then, it works

```
$ bit link --rewire
linked 5 components
api:
original path: src/services/api.js, link path: node_modules/@bit/api/src/services/api.js
authentication-service:
original path: src/services/AuthenticationService.js, link path: node_modules/@bit/authentication-service/src/services/AuthenticationService.js
email-service:
original path: src/services/EmailService.js, link path: node_modules/@bit/email-service/src/services/EmailService.js
store:
original path: src/store.js, link path: node_modules/@bit/store/src/store.js
welcome:
original path: src/components/welcome.vue, link path: node_modules/@bit/welcome/src/components/welcome.vue

rewired 4 components
api:
file: src/services/api.js
authentication-service:
file: src/services/AuthenticationService.js
email-service:
file: src/services/EmailService.js
welcome:
file: src/components/welcome.vue
if you have a compiler set up, please run "bit build" to update the dists as well

$ bit build
building components...
✔ building component - api
✔ building component - authentication-service
✔ building component - email-service
✔ building component - store
✔ building component - welcome
````

Tagging works well also:
bit tag --all 0.1.0 building components... ✔ building component - api ✔ building component - authentication-service ✔ building component - email-service ✔ building component - store ✔ building component - welcome 5 component(s) tagged

But export keep sending an error asking to --rewire and then the same final error again
````
$ bit export digitalproductstudio.trainingapp
please use "--rewire" flag to fix the import/require statements "@bit/store" in "src/services/api.js" file of api,
the current import/require module has no scope-name, which result in an invalid module path upon import
$ bit export digitalproductstudio.trainingapp --rewire
packageNameToComponentId unable to determine the id of api, it has no dot and is not exists on .bitmap
$ bit status
packageNameToComponentId unable to determine the id of api, it has no dot and is not exists on .bitmap
$ bit list
found 0 components in local scope

````

Specifications

Bit version: 14.8.2
Node version: 12.4.0
npm version: 6.11.2
Platform: Vue (vue cli + webpack)
Bit compiler (include version): bit.envs/bundlers/[email protected]
Bit tester (include version): none

typbug

Most helpful comment

Option 1 works like a charme for me ;)
A huge thank you for your reactivity !

All 5 comments

If the components were never exported, then you should set up the default scope before the link --rewire.
The link rewire change the paths to be module paths. however, if you didn't set up a default scope, once you export their names are actually changed, therefor you got this error.
With the new upcoming config, default scope will be mandatory.
Can you please try run (or start fresh and just make sure to set up default scope at the beginning)
bit untag -a
setup default scope in bit.json / package.json
bit link --rewire
bit tag -a
bit export (no need to pass the scope name here since it's already configured in the default scope)

this is a result of a kind of mixing state. we will make sure to improve those errors and instructions.

@davidfirst FYI

@GiladShoham , are we currently assume that defaultScope is mandatory in packageNameToComponentId? If so, we should fix it there to either make it mandatory or allow parsing it.

About the solution, since @thibaultchazal was already running bit link --rewire, all relative-paths were changed, so running it again will only change the node-modules symlinks but not the import/require statements in the code.

About the solution, since @thibaultchazal was already running bit link --rewire, all relative-paths were changed, so running it again will only change the node-modules symlinks but not the import/require statements in the code

I just thought about it as well.. probably need to run a search and replace as well. or start fresh.

are we currently assume that defaultScope is mandatory in packageNameToComponentId? If so, we should fix it there to either make it mandatory or allow parsing it.

let's talk about it offline

Correct.
@thibaultchazal , if you have the code before you were running the link --rewire, please revert it.
Then, you have two options:

  1. set the defaultScope first and then run bit link --rewire. This will replace all relative paths to module paths.
  2. do nothing. in this version, you don't have to replace the relative-paths. just tag and export without running bit link --rewire.

Option 1 works like a charme for me ;)
A huge thank you for your reactivity !

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nvthuong1996 picture nvthuong1996  Â·  13Comments

FredyC picture FredyC  Â·  20Comments

yairEO picture yairEO  Â·  19Comments

JoshK2 picture JoshK2  Â·  12Comments

iboldurev picture iboldurev  Â·  12Comments