yarnpkg / yarn

The 1.x line is frozen - features and bugfixes now happen on https://github.com/yarnpkg/berry
https://classic.yarnpkg.com
Other
41.44k stars 2.73k forks source link

can't add local js file getting directory error Error: ENOTDIR #5537

Open kumarravisingh opened 6 years ago

kumarravisingh commented 6 years ago

I am adding a local js file of owl crousel2 since it is not on packagist and getting this error log.

Arguments: /usr/local/bin/node /usr/bin/yarn install --verbose

PATH: /home/vagrant/.composer/vendor/bin:/usr/local/go/bin:/home/vagrant/bin:/home/vagrant/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

Yarn version: 1.5.1

Node version: 9.8.0

Platform: linux x64

npm manifest: { "private": true, "scripts": { "dev": "npm run development", "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", "watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", "watch-poll": "npm run watch -- --watch-poll", "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js", "prod": "npm run production", "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js" }, "devDependencies": { "axios": "^0.18", "babel-preset-env": "^1.6.1", "babel-preset-stage-3": "^6.24.1", "bootstrap": "^4.0.0", "cross-env": "^5.1", "jquery": "^3.3.1", "laravel-mix": "^2.0", "lodash": "^4.17.4", "popper.js": "^1.12", "vue": "^2.5.7" }, "dependencies": { "babel-plugin-transform-object-rest-spread": "^6.26.0", "collect.js": "^4.0.2", "components-jqueryui": "components/jqueryui", "datatables.net": "^1.10.16", "magnific-popup": "dimsemenov/magnific-popup", "vuex": "^3.0.1", "owl-carousel": "file:./resources/assets/plugins/owl.carousel.min.js" } }

yarn manifest: No manifest

Lockfile: No lockfile

Trace: Error: ENOTDIR: not a directory, scandir '/home/vagrant/.cache/yarn/v1/npm-owl-carousel-0.0.0-85ced548-53fd-4ee3-b759-7fb280329034-1521394261150'

this is inside homestead vagrant of laravel

same is happening in windows 10 also outside virtualbox

rally25rs commented 6 years ago
"owl-carousel": "file:./resources/assets/plugins/owl.carousel.min.js"

I don't think you can do that 🤔 I'm pretty sure yarn is going to expect the path to be an npm package (a directory with a package.json file in it)

You could probably make a directory, make a package.json in it with a name and version, and put that owl.carousel.min.js file in it.

Since it's apparently tried to do something in the cache, you might end up with a corrupted cache entry that you should be able to clean up with yarn cache clean owl-carousel

jschertz commented 6 years ago

The import requires a directory, here's what I did in a similar situation:

  1. Add a directory (e.g. ./resources/assets/plugins/owl)
  2. Put your local js file in there
  3. Add package.json file to directory with the following:
    
    {
    "name": "owl-carousel",
    "version": "2.0.0",
    "private": true,
    "main": "./owl.carousel.min.js"
    }
4. Add this to your package.json:
```json
"owl-carousel": "./resources/assets/plugins/owl"
  1. Run yarn