Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERR_INVALID_ARG_TYPE The "path" argument must be of type string webpack #979

Closed
wcoc opened this issue Jun 8, 2020 · 3 comments
Closed
Labels
bug Something isn't working bundler community core
Milestone

Comments

@wcoc
Copy link

wcoc commented Jun 8, 2020

Describe the bug
I already followed the simple steps, but it isn't working for me...
when I'm trying to run the project with this dependecy, I got this problem:

internal/validators.js:125
    throw new ERR_INVALID_ARG_TYPE(name, 'string', value);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
    at validateString (internal/validators.js:125:11)
    at Object.dirname (path.js:1121:5)
    at findRoot (/home/wcologn/Projects/test/dist/app.js:13490:62)
    at findPkg (/home/wcologn/Projects/test/dist/app.js:13494:15)
    at Object.<anonymous> (/home/wcologn/Projects/test/dist/app.js:13500:18)
    at __webpack_require__ (/home/wcologn/Projects/test/dist/app.js:21:30)
    at Object.<anonymous> (/home/wcologn/Projects/test/dist/app.js:8431:13)
    at __webpack_require__ (/home/wcologn/Projects/test/dist/app.js:21:30)
    at Object.<anonymous> (/home/wcologn/Projects/test/dist/app.js:21203:14)
    at __webpack_require__ (/home/wcologn/Projects/test/dist/app.js:21:30)

the line 13490 from app.js is this one from method name findRoot () {:

return __webpack_require__.c[__webpack_require__.s] ? path.dirname(__webpack_require__.c[__webpack_require__.s].filename) : process.cwd()

it's something related to pkg but i don't know what exactly is it.

somebody already had successfully to do it with webpack?

my webpack.config.js:

const path = require("path");
const webpack = require('webpack');

module.exports = (env, argv) => {
  return {
    entry: './src/app.ts',
    output: {
      filename: "app.js",
      libraryTarget: "commonjs2",
      path: path.resolve(__dirname, 'dist')
    },

    resolve: {
      alias: {
        src: path.resolve(__dirname, "src")
      },
      extensions: [".ts", ".js", ".json"]
    },

    target: "node",

    mode: process.env.NODE_ENV || 'production',
    devtool: "inline-source-map",
    // Add the TypeScript loader
    module: {
      rules: [
        {
          test: /\.tsx?$/,
          exclude: /node_modules/,
          loader: "ts-loader"
        }
      ]
    },
    optimization: {
      // We no not want to minimize our code.
      minimize: false
    },
    plugins: [
      new webpack.ContextReplacementPlugin(/dd-trace(\\|\/)/)
    ]
  }
};

my package.json:

{
  "name": "test-2020",
  "version": "0.1.0",
  "description": "test.",
  "private": true,
  "main": "./src/app.js",
  "scripts": {
    "build": "webpack-cli"
  },
  "keywords": [
    "nodejs",
    "node",
    "sync",
    "licensing",
    "elasticsearch",
    "mysql"
  ],
  "author": "Willian Colognesi",
  "license": "ISC",
  "engines": {
    "npm": ">=10"
  },
  "dependencies": {
    "dd-trace": "0.20.3",
    "graphql": "^15.0.0",
    "reflect-metadata": "^0.1.13",
    "spdx-exceptions": "^2.3.0",
    "typescript": "^3.9.3"
  },
  "devDependencies": {
    "@types/node": "^12.0.2",
    "@types/supertest": "^2.0.8",
    "@types/hapi__joi": "^15.0.2",
    "@types/jest": "^24.0.15",
    "tslint": "^5.16.0",
    "ts-jest": "^24.0.2",
    "ts-loader": "^6.0.1",
    "ts-node": "^8.1.0",
    "tslint-config-prettier": "^1.18.0",
    "tslint-config-standard": "^8.0.1",
    "webpack": "^4.32.2",
    "webpack-cli": "^3.3.2",
    "webpack-node-externals": "^1.7.2"
  }
}

app.ts:

import './tracer.ts'

console.log('test!')

tracer.ts

import tracer from 'dd-trace';

tracer.init();
export default tracer;

Environment

@wcoc wcoc added the bug Something isn't working label Jun 8, 2020
@wcoc
Copy link
Author

wcoc commented Jun 8, 2020

tsconfig.json as well:

{
  "compilerOptions": {
    "module": "commonjs",
    "esModuleInterop": true,
    "target": "es6",
    "typeRoots": ["node_modules/@types"],
    "types": ["reflect-metadata", "jest"],
    "lib": ["es2017", "dom"],
    "noImplicitAny": true,
    "strictNullChecks": true,
    "resolveJsonModule": true,
    "moduleResolution": "node",
    "sourceMap": true,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "baseUrl": ".",
    "paths": {
      "src/*": ["src/*"]
    }
  },
  "include": [
    "./src/**/*.ts"
  ],
  "exclude": [
    "node_modules",
    "**/*.spec.ts"
  ]
}

@rochdev rochdev added this to the 0.21.1 milestone Jun 9, 2020
@rochdev
Copy link
Member

rochdev commented Jun 9, 2020

Fixed in #973. It will be in 0.21.1 which I'll try to release tomorrow.

@rochdev
Copy link
Member

rochdev commented Jun 11, 2020

Just released in 0.21.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working bundler community core
Projects
None yet
Development

No branches or pull requests

3 participants