question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

decorate-angular-cli.js requires @nrwl/workspace to be a dependency rather than a devDependency

See original GitHub issue

Current Behavior

The script requires @nrwl/workspace, but that package doesn’t get installed when using a script such as npm ci --only=production --no-optional --no-audit. I’m using this to build the production Dockerfile of our project, but it now fails because @nrwl/workspace is a devDependency.

Expected Behavior

The decorate-angular-cli.js script should also work when using npm ci --only=production

Error log

> didowi@0.0.0 setup:prod /app
> npm ci --only=production --no-optional --no-audit

npm WARN prepare removing existing node_modules/ before installation

> leveldown@5.4.1 install /app/node_modules/leveldown
> node-gyp-build


> level@6.0.0 postinstall /app/node_modules/level
> opencollective-postinstall || exit 0


> core-js@3.6.5 postinstall /app/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"


> @nestjs/core@7.1.3 postinstall /app/node_modules/@nestjs/core
> opencollective || exit 0

                           Thanks for installing nest 
                 Please consider donating to our open collective
                        to help us maintain this package.
                                         
                           Number of contributors: 457
                              Number of backers: 382
                              Annual budget: $41,235
                             Current balance: $4,596
                                         
             Become a partner: https://opencollective.com/nest/donate
                                         

> didowi@0.0.0 postinstall /app
> node ./decorate-angular-cli.js

internal/modules/cjs/loader.js:796
    throw err;
    ^

Error: Cannot find module '@nrwl/workspace'
Require stack:
- /app/decorate-angular-cli.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:793:17)
    at Function.Module._load (internal/modules/cjs/loader.js:686:27)
    at Module.require (internal/modules/cjs/loader.js:848:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/app/decorate-angular-cli.js:28:20)
    at Module._compile (internal/modules/cjs/loader.js:955:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
    at Module.load (internal/modules/cjs/loader.js:811:32)
    at Function.Module._load (internal/modules/cjs/loader.js:723:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/app/decorate-angular-cli.js' ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! didowi@0.0.0 postinstall: `node ./decorate-angular-cli.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the didowi@0.0.0 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/node/.npm/_logs/2020-06-15T10_31_30_851Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! didowi@0.0.0 setup:prod: `npm ci --only=production --no-optional --no-audit`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the didowi@0.0.0 setup:prod script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/node/.npm/_logs/2020-06-15T10_31_30_944Z-debug.log

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:11
  • Comments:13

github_iconTop GitHub Comments

16reactions
jared-christensencommented, Feb 10, 2021

So what is the fix? I need to update something or use that no scripts flag?

6reactions
balteocommented, Jan 21, 2022

Any fix or workaround? I am facing the same issue… Why was this issue closed by the way? I am using the latest nx and I still get the error…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why am i getting error on using any `nx` commands
Just had this issue myself. Fixed it by deleting all my node_modules, verifying npm cache, updating my global @nrwl-cli, and reinstalling.
Read more >
Migrating an Angular CLI project to Nx
Adds a decorate-angular-cli.js to the root of your workspace, and a postinstall script in your package.json to run the script when your dependencies...
Read more >
nx jest unexpected token 'export' - You.com | The AI Search ...
Problem. When I run jest, on some test it will throw an error about failure to import .js files with export in them....
Read more >
rush add
Adds specified package(s) to the dependencies of the current project (as ... "rush add --package "example@^1.2.3"" instead of
Read more >
@nrwl/node: Versions | Openbase
angular: skip invalid projects or targets instead of erroring when migrating ... js: move swc/helpers to dependencies instead of devDependencies (#10275) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found