pnpm monorepo made with create-nx-workspace cannot immediately lint
See original GitHub issueCurrent Behavior
Cannot lint in a fresh monorepo without complaints about ‘dotenv’. If I install dotenv
globally, then it complains about more and more packages that need to be installed.
To get it to work, I had to install the following with pnpm add -D
"dotenv": "^16.0.1",
"eslint": "^8.21.0",
"@nrwl/eslint-plugin-nx": "^14.5.2",
"@typescript-eslint/eslint-plugin": "^5.32.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-unicorn": "^43.0.2",
Upon inspection, it makes sense that I would need these installed in order to be able to lint, and I know pnpm doesn’t hoist by default (and I know why that is a benefit). Perhaps the issue is that when I use the create-nx-workspace
and I add my first library, perhaps I expect that these should be automatically installed (when using pnpm) just as things like jest are installed the first time I create a library.
And if this is the wrong place to post this, I’m happy to create an issue elsewhere and close this one.
Expected Behavior
In a fresh pnpm monorepo, I should be able to create a library and lint said library without package errors.
Steps to Reproduce
pnpx create-nx-workspace && pnpm nx g library example && pnpm nx lint example
Failure Logs
$ pnpm nx lint example
> NX Cannot find module 'dotenv'
Require stack:
- /home/troy/Code/work/didit/node_modules/.pnpm/@nrwl+nx-cloud@14.3.0/node_modules/@nrwl/nx-cloud/lib/utilities/environment.js
- /home/troy/Code/work/didit/node_modules/.pnpm/@nrwl+nx-cloud@14.3.0/node_modules/@nrwl/nx-cloud/lib/nx-cloud-tasks-runner.js
- /home/troy/Code/work/didit/node_modules/.pnpm/@nrwl+nx-cloud@14.3.0/node_modules/@nrwl/nx-cloud/index.js
- /home/troy/Code/work/didit/node_modules/.pnpm/nx@14.5.1/node_modules/nx/src/tasks-runner/run-command.js
- /home/troy/Code/work/didit/node_modules/.pnpm/nx@14.5.1/node_modules/nx/src/command-line/run-one.js
- /home/troy/Code/work/didit/node_modules/.pnpm/nx@14.5.1/node_modules/nx/src/command-line/nx-commands.js
- /home/troy/Code/work/didit/node_modules/.pnpm/nx@14.5.1/node_modules/nx/bin/init-local.js
- /home/troy/Code/work/didit/node_modules/.pnpm/nx@14.5.1/node_modules/nx/bin/nx.js
Pass --verbose to see the stacktrace.
Environment
$ pnpm nx report
> NX Report complete - copy this into the issue template
Node : 16.16.0
OS : linux x64
pnpm : 7.8.0
nx : 14.5.1
@nrwl/angular : Not Found
@nrwl/cypress : Not Found
@nrwl/detox : Not Found
@nrwl/devkit : Not Found
@nrwl/eslint-plugin-nx : Not Found
@nrwl/express : Not Found
@nrwl/jest : 14.5.1
@nrwl/js : Not Found
@nrwl/linter : Not Found
@nrwl/nest : Not Found
@nrwl/next : Not Found
@nrwl/node : Not Found
@nrwl/nx-cloud : 14.3.0
@nrwl/nx-plugin : Not Found
@nrwl/react : Not Found
@nrwl/react-native : Not Found
@nrwl/schematics : Not Found
@nrwl/storybook : Not Found
@nrwl/web : Not Found
@nrwl/workspace : 14.5.1
typescript : 4.7.4
---------------------------------------
Community plugins:
Issue Analytics
- State:
- Created a year ago
- Comments:11 (4 by maintainers)
Top GitHub Comments
@troywweber7, sorry for the inconvenience.
I have reached out to our colleaguesthe from
nx-cloud
team and someone will pick it up soon. Please do not continue the thread on (this) closed issue, especially since you opened another dedicated one.In the meantime, as @barbados-clemens mentioned you can switch back to hosting to until we roll out the fixed version.
@meeroslav It’s not in peer dependencies either:
The problem appeared after I disabled hoisting. Probably some other package was installing
dotenv
and thats why it worked with hoisting. Without hoisting the package only has access to what’s declared in it’spackage.json
.Anyway, I don’t think its a good idea to rely hoisting for the package to work. The behaviour is different between package managers and could change.