안녕하세요.
다음과 같은 오류가 발생해서 질문드립니다.
(base) ~/WebstormProjects/untitled1 npm init -y
(base) ~/WebstormProjects/untitled1 npm i csv (csv-parse 계속 오류나길래 전체 패키지로 해봤습니다.)
(base) ~/WebstormProjects/untitled1 node index
index.js
const parse = require('csv-parse/dist/cjs/sync.cjs')
오류
node:internal/modules/cjs/loader:488
throw e;
^
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './dist/cjs/sync.cjs' is not defined by "exports" in /Users/username/WebstormProjects/untitled1/node_modules/csv-parse/package.json
at new NodeError (node:internal/errors:371:5)
at throwExportsNotFound (node:internal/modules/esm/resolve:440:9)
at packageExportsResolve (node:internal/modules/esm/resolve:692:3)
at resolveExports (node:internal/modules/cjs/loader:482:36)
at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/Users/jeonsiwon/WebstormProjects/untitled1/index.js:1:15) {
code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}
시도해본 방법
https://stackoverflow.com/questions/69693907/error-err-package-path-not-exported-package-subpath-lib-tokenize-is-not-d
참고하여 LTS 노드로 재 설치해서 시도했는데 동일한 오류가 계속 발생하네요..
I am also stuck with the same problem because I installed the latest version of Node.js (v17.0.1).
Just go for node.js v14.18.1
and remove the latest version just use the stable version v14.18.1
nvm uninstall <version>
OR
nvm uninstall v17.0.1
then install the LTS
one which is v14.18.1
nvm install --lts
This worked for me.
package.json (untitled1)
{
"name": "untitled1",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"csv": "^6.0.5"
}
}
package.json (csv-parse/package.json)
{
"version": "5.0.4",
"name": "csv-parse",
"description": "CSV parsing implementing the Node.js `stream.Transform` API",
"keywords": [
"csv",
"parse",
"parser",
"convert",
"tsv",
"stream"
],
"author": "David Worms <david@adaltas.com> (https://www.adaltas.com)",
"contributors": [
"David Worms <david@adaltas.com> (https://www.adaltas.com)",
"Will White (https://github.com/willwhite)",
"Justin Latimer (https://github.com/justinlatimer)",
"jonseymour (https://github.com/jonseymour)",
"pascalopitz (https://github.com/pascalopitz)",
"Josh Pschorr (https://github.com/jpschorr)",
"Elad Ben-Israel (https://github.com/eladb)",
"Philippe Plantier (https://github.com/phipla)",
"Tim Oxley (https://github.com/timoxley)",
"Damon Oehlman (https://github.com/DamonOehlman)",
"Alexandru Topliceanu (https://github.com/topliceanu)",
"Visup (https://github.com/visup)",
"Edmund von der Burg (https://github.com/evdb)",
"Douglas Christopher Wilson (https://github.com/dougwilson)",
"Joe Eaves (https://github.com/Joeasaurus)",
"Mark Stosberg (https://github.com/markstos)"
],
"exports": {
".": {
"import": "./lib/index.js",
"require": "./dist/cjs/index.cjs"
},
"./sync": {
"import": "./lib/sync.js",
"require": "./dist/cjs/sync.cjs"
},
"./browser/esm": "./dist/esm/index.js",
"./browser/esm/sync": "./dist/esm/sync.js"
},
"devDependencies": {
"@rollup/plugin-eslint": "^8.0.1",
"@rollup/plugin-node-resolve": "^13.0.6",
"@types/mocha": "^9.0.0",
"@types/node": "^16.11.7",
"coffeelint": "^2.1.0",
"coffeescript": "^2.6.1",
"csv-generate": "^4.0.4",
"csv-spectrum": "^1.0.0",
"each": "^1.2.2",
"eslint": "^8.2.0",
"mocha": "^9.1.3",
"pad": "^3.2.0",
"rollup": "^2.60.0",
"rollup-plugin-node-builtins": "^2.1.2",
"rollup-plugin-node-globals": "^1.4.0",
"should": "^13.2.3",
"stream-transform": "^3.0.4",
"ts-node": "^10.4.0",
"typescript": "^4.4.4"
},
"files": [
"dist",
"lib"
],
"homepage": "https://csv.js.org/parse/",
"license": "MIT",
"main": "./dist/cjs/index.cjs",
"mocha": {
"inline-diffs": true,
"loader": "./test/loaders/all.mjs",
"recursive": true,
"reporter": "spec",
"require": [
"should"
],
"throw-deprecation": true,
"timeout": 40000
},
"repository": {
"type": "git",
"url": "https://github.com/adaltas/node-csv.git",
"directory": "packages/csv-parse"
},
"scripts": {
"build": "npm run build:rollup && npm run build:ts",
"build:rollup": "npx rollup -c",
"build:ts": "cp lib/*.ts dist/cjs && cp lib/*.ts dist/esm",
"lint": "npm run lint:lib && npm run lint:samples && npm run lint:test",
"lint:lib": "eslint --fix lib/*.js",
"lint:samples": "eslint --fix samples/*.js",
"lint:test": "coffeelint --fix test/*.coffee",
"preversion": "npm run build && git add dist",
"pretest": "npm run build",
"test": "mocha 'test/**/*.{coffee,ts}'",
"test:legacy": "mocha --loader=./test/loaders/legacy/all.mjs 'test/**/*.{coffee,ts}'"
},
"type": "module",
"types": "dist/esm/index.d.ts",
"typesVersions": {
"*": {
".": [
"dist/esm/index.d.ts"
],
"sync": [
"dist/esm/sync.d.ts"
],
"browser/esm": [
"dist/esm/index.d.ts"
],
"browser/esm/sync": [
"dist/esm/sync.d.ts"
]
}
},
"gitHead": "bab8d89a6eb3bc073233e27b7af0a50284b1590f"
}