javascript-tutorial/server

BUG - ./edit command fails - throwing error - cannot find module 'stylus'

jonnathan-ls opened this issue ยท 1 comments

๐Ÿž Bug

Cannot find module 'stylus'

๐ŸŽฏ Context

Execution of server project locally to test site translation initiative

๐Ÿ’ฃ Problem

After cloning the repositories (serve and module and repo) and installing the dependencies, the attempt to execute the command ./edit to load the application ends up failing, as shown in the following log:

โ™จ๏ธ  server git:(master) ./edit pt 
[23:39:06] Using gulpfile ~/Desktop/desktop/javascript-info/server/gulpfile.js
[23:39:06] Starting 'edit'...
[23:39:06] Starting 'webpack'...
[23:39:06] Starting 'engine:koa:tutorial:importWatch'...
[23:39:06] Starting 'livereload'...
[23:39:06] Starting 'server'...
Livereload server listening
02:39:08.710Z  INFO application: Boot complete
[23:39:08] 'webpack' errored after 2.6 s
[23:39:08] Error: Cannot find module 'stylus'
Require stack:
- /Users/t719516/Desktop/desktop/javascript-info/server/node_modules/nib/lib/nib.js
- /Users/t719516/Desktop/desktop/javascript-info/server/modules/config/webpack.js
- /Users/t719516/Desktop/desktop/javascript-info/server/modules/config/index.js
- /Users/t719516/Desktop/desktop/javascript-info/server/gulpfile.js
- /Users/t719516/Desktop/desktop/javascript-info/server/node_modules/gulp/node_modules/gulp-cli/lib/shared/require-or-import.js
- /Users/t719516/Desktop/desktop/javascript-info/server/node_modules/gulp/node_modules/gulp-cli/lib/versioned/^4.0.0/index.js
- /Users/t719516/Desktop/desktop/javascript-info/server/node_modules/gulp/node_modules/gulp-cli/index.js
- /Users/t719516/Desktop/desktop/javascript-info/server/node_modules/gulp/bin/gulp.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/Users/t719516/Desktop/desktop/javascript-info/server/node_modules/nib/lib/nib.js:11:14)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
[23:39:08] 'edit' errored after 2.6 s

๐Ÿ” Reason

The problem is due to the fact that two project libs (nib and stylus-loader) depend on the stylus library, as NPM warns right after installing the dependencies:

npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN nib@1.2.0 requires a peer of stylus@* but none is installed. You must install peer dependencies yourself.
npm WARN stylus-loader@3.0.2 requires a peer of stylus@>=0.52.4 but none is installed. You must install peer dependencies yourself.

added 1471 packages from 894 contributors and audited 1475 packages in 392.365s

68 packages are looking for funding
  run `npm fund` for details

found 47 vulnerabilities (37 moderate, 10 high)
  run `npm audit fix` to fix them, or `npm audit` for details

โœ… Expected

Execution of the command, without any failure.

๐Ÿ› ๏ธ Solution

Installing the stylusdependency solved the problem.

โ™จ๏ธ  server git:(master) npm i stylus
npm WARN deprecated source-map-resolve@0.6.0: See https://github.com/lydell/source-map-resolve#deprecated
+ stylus@0.58.1
added 7 packages from 42 contributors and audited 1482 packages in 10.004s

68 packages are looking for funding
  run `npm fund` for details

found 47 vulnerabilities (37 moderate, 10 high)
  run `npm audit fix` to fix them, or `npm audit` for details
  
โ™จ๏ธ  server git:(master) โœ— ./edit en                                                          
[23:53:35] Using gulpfile ~/Desktop/desktop/javascript-info/server/gulpfile.js
[23:53:35] Starting 'edit'...
... LOG OMITTED ...
02:54:02.426Z  INFO importWatch: Import complete

๐ŸŒ Environmentl

  • Node: 14.16.1
  • Npm: 6.14.12

๐Ÿ—ณ๏ธ Suggestion

Add a dependency on the project's package.json.

๐Ÿท๏ธ Labels

~Bug ~Dependencies ~Install ~Server

I hope works now, many updates internally.