Closed NovaMachina closed 2 years ago
+1 on this issue, I'm having it too. Tried finding a workaround by creating a workspace library then exporting all from the npm module but that didn't do anything.
Help is needed on this issue!
I am experiencing the same problem after adding a nodejs app to my nx workspace, I have applied the fix above locally and can confirm that this resolves the issue for me
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.
Current Behavior
Following the Nx documentation for TypeScript projects I have discovered an issue when importing a npm package into a barebones TypeScript application and then using it in a TS file. It would appear that there is an issue resolving npm packages in TypeScript workspaces.
I did some digging into the stack trace (provided below) and discovered that in
@nrwl/js/src/executors/node/node.impl.js
thatdependencies
on line 62 is filled out with the npm package in question, however theoutputs
array is empty. This then results in the path joining failing on line 65.dependencies
object:Here is the repo that I am using: https://github.com/NovaMachina/payroll-etl
Expected Behavior
Importing npm packages should not break the compilation process and should be able to be used in TypeScript files.
Steps to Reproduce
The following steps were taken:
npx create-nx-workspace happynrwl --preset=ts
ts
optionNo
to Nx Cloudcd happynrwl
nx generate @nrwl/js:app demoapp
npm install axios
packages/demoapp/src/app/demoapp.ts
to includeimport axios from 'axios';
as line 1nx serve demoapp
What is interesting though, is that if you comment out
import axios from 'axios';
then runnx serve demoapp
, compilation will succeed. Uncommentingimport axios from 'axios';
while the Nx process is still running will result in everything working correctly. However, if you then stop the Nx process and restart it withnx serve demoapp
, the above error will return.Failure Logs
Environment
Node : 16.13.0 OS : linux x64 npm : 8.3.0
nx : 13.4.1 @nrwl/angular : undefined @nrwl/cli : 13.4.1 @nrwl/cypress : undefined @nrwl/devkit : 13.4.1 @nrwl/eslint-plugin-nx : 13.4.1 @nrwl/express : undefined @nrwl/jest : 13.4.1 @nrwl/linter : 13.4.1 @nrwl/nest : undefined @nrwl/next : undefined @nrwl/node : undefined @nrwl/nx-cloud : undefined @nrwl/react : undefined @nrwl/react-native : undefined @nrwl/schematics : undefined @nrwl/tao : 13.4.1 @nrwl/web : undefined @nrwl/workspace : 13.4.1 @nrwl/storybook : undefined @nrwl/gatsby : undefined typescript : 4.4.4 rxjs : 6.6.7
Community plugins: @nrwl/js: 13.4.1
(node:198277) [DEP0148] DeprecationWarning: Use of deprecated folder mapping "./" in the "exports" field module resolution of the package at /home/jacob/Projects/TrackNow/happynrwl/node_modules/tslib/package.json. Update this package.json to use a subpath pattern like "./*". (Use
node --trace-deprecation ...
to show where the warning was created)