server
server copied to clipboard
BUG - ./edit command fails - throwing error - cannot find module 'stylus'
🐞 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 [email protected] requires a peer of stylus@* but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] 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 [email protected]: See https://github.com/lydell/source-map-resolve#deprecated
+ [email protected]
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