FredKSchott / snowpack

ESM-powered frontend build tool. Instant, lightweight, unbundled development. ✌️
https://www.snowpack.dev
MIT License
19.48k stars 921 forks source link

Dependency Load Error ENOENT: no such file or directory... #3815

Open gengns opened 2 years ago

gengns commented 2 years ago

Quick checklist

What package manager are you using?

npm

What operating system are you using?

Linux

Describe the bug

After updating Snowpack in a working project, Snowpack is not able to find some dependencies. In this case we are just trying to render a web component button using Vaadin but it happens with other libraries as well.

Steps to reproduce

  1. clone repo
  2. install packages
  3. npm run start
  4. [snowpack] Error ENOENT: no such file or directory...

If we use a previous Snowpack version everything works as expected.

Link to minimal reproducible example

https://github.com/gengns/snowpack_3.8.8_dependency_error

aardvarkk commented 2 years ago

I am also receiving this error. For me, I get it when prepping dependencies for @aws-amplify. I receive it on both versions 3.8.7 and 3.8.8, but the error does not occur in 3.8.6.

jaedson-barbosa commented 2 years ago

Same thing here. I noticed that in version 3.8.6 several packages have one (dedupe) and the same doesn't happen in 3.8.8.

Jazzmanpw commented 2 years ago

I have the same issue, I guess. The most interesting part is that it happens only when I try to load the page. The "initial" build runs successfully.

I've just upgraded to the latest version, and I have several types of messages from Snowpack:

"Unscannable" warning ``` [14:45:42] [snowpack] lodash-es/merge: Unscannable package import found. Snowpack scans source files for package imports at startup, and on every change. But, sometimes an import gets added during the build process, invisible to our file scanner. We'll prepare this package for you now, but should add "lodash-es/merge" to "knownEntrypoints" in your config file so that this gets prepared with the rest of your imports during startup. ```

and the same for several other lodash-es functions. Snowpack adds them after these messages. And then it fails with

"No such file or directory" error ``` [14:45:47] [snowpack] [Error: ENOENT: no such file or directory, open 'E:\JS\film-list\node_modules\.cache\snowpack\build\lodash-es@4.17.21\common\_baseClone-d1480cc6.js'] { errno: -4058, code: 'ENOENT', syscall: 'open', path: 'E:\\JS\\film-list\\node_modules\\.cache\\snowpack\\build\\lodash-es@4.17.21\\common\\_baseClone-d1480cc6.js' } [14:45:47] [snowpack] Error: ENOENT: no such file or directory, open 'E:\JS\film-list\node_modules\.cache\snowpack\build\lodash-es@4.17.21\common\_baseClone-d1480cc6.js' [14:45:47] [snowpack] [500] /_snowpack/pkg/lodash-es.v4.17.21/common/_baseClone-d1480cc6.js ```

I do not depend directly on the lodash which makes it even weirder. This is the tree Snowpack shows while building the dependencies:

Dependencies tree ``` [14:45:15] [snowpack] + @fortawesome/free-solid-svg-icons@5.15.4 [14:45:16] [snowpack] + @fortawesome/react-fontawesome@0.1.16 [14:45:16] [snowpack] └── @fortawesome/fontawesome-svg-core@1.2.36 [14:45:17] [snowpack] └── prop-types@15.7.2 [14:45:17] [snowpack] └── react-is@16.13.1 [14:45:17] [snowpack] └── object-assign@4.1.1 [14:45:17] [snowpack] └── react@17.0.2 (dedupe) [14:45:18] [snowpack] + clsx@1.1.1 [14:45:18] [snowpack] + country-flag-icons/react/3x2@1.4.19 [14:45:18] [snowpack] + formik@2.2.9 [14:45:19] [snowpack] └── react-fast-compare@2.0.4 [14:45:19] [snowpack] └── deepmerge@2.2.1 [14:45:19] [snowpack] └── lodash-es/isPlainObject@4.17.21 [14:45:19] [snowpack] └── lodash-es/clone@4.17.21 [14:45:20] [snowpack] └── lodash-es/toPath@4.17.21 [14:45:20] [snowpack] └── tiny-warning@1.0.3 [14:45:20] [snowpack] └── hoist-non-react-statics@3.3.2 [14:45:21] [snowpack] └── lodash-es/cloneDeep@4.17.21 [14:45:21] [snowpack] + normalizr@3.6.1 [14:45:22] [snowpack] + ramda@0.27.1 [14:45:23] [snowpack] + react-color@2.19.3 [14:45:23] [snowpack] └── reactcss@1.2.3 [14:45:23] [snowpack] └── lodash/isString@4.17.21 [14:45:24] [snowpack] └── lodash/forOwn@4.17.21 [14:45:24] [snowpack] └── lodash/isPlainObject@4.17.21 [14:45:25] [snowpack] └── lodash/map@4.17.21 [14:45:26] [snowpack] └── lodash/cloneDeep@4.17.21 [14:45:27] [snowpack] └── tinycolor2@1.4.2 [14:45:28] [snowpack] └── material-colors@1.2.6 [14:45:28] [snowpack] └── @icons/material/UnfoldMoreHorizontalIcon@0.2.4 [14:45:28] [snowpack] └── @icons/material/CheckIcon@0.2.4 [14:45:28] [snowpack] + react-dom@17.0.2 [14:45:30] [snowpack] └── scheduler@0.20.2 [14:45:30] [snowpack] └── scheduler/tracing@0.20.2 [14:45:30] [snowpack] + react-query@3.34.7 [14:45:31] [snowpack] + react-query/devtools@3.34.7 [14:45:31] [snowpack] └── match-sorter@6.3.0 [14:45:32] [snowpack] └── remove-accents@0.4.2 [14:45:32] [snowpack] + react-router-dom@6.2.1 [14:45:32] [snowpack] └── history@5.2.0 [14:45:32] [snowpack] └── react-router@6.2.1 [14:45:32] [snowpack] + reactjs-popup@2.0.5 [14:45:32] [snowpack] + recoil@0.5.2 [14:45:33] [snowpack] + use-debounce@7.0.1 ```
package.json ``` { "name": "film-list", "license": "MIT", "description": "see readme for description", "version": "0.0.1", "author": { "name": "Dmitry Shpak", "email": "hummer.revolver@gmail.com", "url": "https://vk.com/hummer__revolver" }, "repository": { "url": "htps://github.com/Jazzmanpw/film-list" }, "scripts": { "start": "snowpack dev", "build": "snowpack build", "test": "web-test-runner \"src/**/*.test.tsx\"", "format": "prettier --write \"src/**/*.{js,jsx,ts,tsx}\"", "lint": "prettier --check \"src/**/*.{js,jsx,ts,tsx}\"", "initialize": "node ./scripts/generate-countries.js" }, "dependencies": { "@fortawesome/fontawesome-svg-core": "^1.2.35", "@fortawesome/free-solid-svg-icons": "^5.15.3", "@fortawesome/react-fontawesome": "^0.1.16", "clsx": "^1.1.1", "country-flag-icons": "^1.4.19", "formik": "^2.2.9", "immer": "^9.0.7", "normalizr": "^3.6.1", "ramda": "^0.27.1", "react": "^17.0.2", "react-color": "^2.19.3", "react-dom": "^17.0.2", "react-query": "^3.34.7", "react-router-dom": "^6.2.1", "reactjs-popup": "^2.0.4", "recoil": "^0.5.2", "use-debounce": "^7.0.1" }, "devDependencies": { "@snowpack/plugin-dotenv": "^2.2.0", "@snowpack/plugin-postcss": "^1.4.1", "@snowpack/plugin-react-refresh": "^2.5.0", "@snowpack/plugin-typescript": "^1.2.1", "@snowpack/web-test-runner-plugin": "^0.2.2", "@testing-library/react": "^12.1.2", "@types/chai": "^4.3.0", "@types/jest": "^27.4.0", "@types/ramda": "0.27.40", "@types/react": "^17.0.38", "@types/react-color": "^3.0.6", "@types/react-dom": "^17.0.11", "@types/react-router-dom": "^5.3.2", "@types/snowpack-env": "^2.3.3", "@web/test-runner": "^0.13.25", "autoprefixer": "^10.4.1", "chai": "^4.3.4", "jest": "^27.4.7", "postcss": "^8.4.5", "prettier": "^2.5.1", "snowpack": "3.8.7", "tailwindcss": "^3.0.11", "typescript": "^4.5.4" } } ```
snowpack.config.js ```js /** @type {import("snowpack").SnowpackUserConfig } */ module.exports = { mount: { public: { url: '/', static: true }, src: { url: '/dist' }, assets: { url: '/assets' }, 'node_modules/reactjs-popup/dist': { url: '/reactjs-popup', static: true }, }, plugins: [ '@snowpack/plugin-react-refresh', '@snowpack/plugin-dotenv', '@snowpack/plugin-typescript', '@snowpack/plugin-postcss', ], devOptions: { open: 'none', tailwindConfig: './tailwind.config.js', }, buildOptions: { /* ... */ }, routes: [{ match: 'routes', src: '.*', dest: 'index.html' }], alias: { Generated: './assets/generated', }, } ```