newrelic / gatsby-plugin-newrelic

A Gatsby plugin for instrumenting your site with New Relic's Browser Agent
https://opensource.newrelic.com/projects/newrelic/gatsby-plugin-newrelic
Apache License 2.0
8 stars 19 forks source link

Couldn't find the "gatsby-plugin-newrelic" plugin when installed via yarn #5

Closed jerelmiller closed 4 years ago

jerelmiller commented 4 years ago

Description

When installing this package via yarn, this plugin does not work and fails with the message:

Couldn't find the "gatsby-plugin-newrelic" plugin declared in "/Users/jmiller/code/gatsby-theme-newrelic/packages/gatsby-theme-newrelic/gatsby-config.js".

Tried looking for an installed package in the following paths:
 - /Users/jmiller/code/gatsby-theme-newrelic/node_modules/gatsby/dist/bootstrap/load-themes/node_modules/gatsby-plugin-newrelic
 - /Users/jmiller/code/gatsby-theme-newrelic/node_modules/gatsby/dist/bootstrap/node_modules/gatsby-plugin-newrelic
 - /Users/jmiller/code/gatsby-theme-newrelic/node_modules/gatsby/dist/node_modules/gatsby-plugin-newrelic
 - /Users/jmiller/code/gatsby-theme-newrelic/node_modules/gatsby/node_modules/gatsby-plugin-newrelic
 - /Users/jmiller/code/gatsby-theme-newrelic/node_modules/gatsby-plugin-newrelic
 - /Users/jmiller/code/node_modules/gatsby-plugin-newrelic
 - /Users/jmiller/node_modules/gatsby-plugin-newrelic
 - /Users/node_modules/gatsby-plugin-newrelic
 - /node_modules/gatsby-plugin-newrelic

It appears there is a subtle difference in the files present when installing via npm and yarn. When installing via npm, it appears an index.js file is created in the node module folder:

$ npm install gatsby-plugin-newrelic@newrelic/gatsby-plugin-newrelic.git#master
$ ls -al node_modules/gatsby-plugin-newrelic
total 136
drwxr-xr-x    17 jmiller  staff    544 Jul 15 09:41 .
drwxr-xr-x  1596 jmiller  staff  51072 Jul 15 09:41 ..
-rw-r--r--     1 jmiller  staff    166 Oct 26  1985 .babelrc
drwxr-xr-x     3 jmiller  staff     96 Jul 15 09:41 .github
-rw-r--r--     1 jmiller  staff   3220 Oct 26  1985 CODE_OF_CONDUCT.md
-rw-r--r--     1 jmiller  staff   2509 Oct 26  1985 CONTRIBUTING.md
-rw-r--r--     1 jmiller  staff  11357 Oct 26  1985 LICENSE
-rw-r--r--     1 jmiller  staff   3420 Oct 26  1985 README.md
-rw-r--r--     1 jmiller  staff  11063 Oct 26  1985 THIRD_PARTY_NOTICES.md
drwxr-xr-x     3 jmiller  staff     96 Jul 15 09:41 browser-agents
-rw-r--r--     1 jmiller  staff   5798 Oct 26  1985 cla.md
drwxr-xr-x     3 jmiller  staff     96 Jul 15 09:41 gatsby
-rw-r--r--     1 jmiller  staff    323 Oct 26  1985 gatsby-ssr.js
-rw-r--r--     1 jmiller  staff     21 Oct 26  1985 index.js
-rw-r--r--     1 jmiller  staff   2461 Jul 15 09:41 package.json
drwxr-xr-x     6 jmiller  staff    192 Jul 15 09:41 src
-rw-r--r--     1 jmiller  staff   4446 Oct 26  1985 third_party_manifest.json

When installing via yarn, it appears that the index.js file is missing.

$ yarn add gatsby-plugin-newrelic@newrelic/gatsby-plugin-newrelic.git#master
$ ls -al node_modules/gatsby-plugin-newrelic
total 408
drwxr-xr-x    17 jmiller  staff     544 Jul 15 10:30 .
drwxr-xr-x  1149 jmiller  staff   36768 Jul 15 10:30 ..
-rw-r--r--     1 jmiller  staff     166 Jul 14 15:32 .babelrc
drwxr-xr-x     3 jmiller  staff      96 Jul 15 10:30 .github
-rw-r--r--     1 jmiller  staff      65 Jul 14 15:32 .gitignore
-rw-r--r--     1 jmiller  staff      14 Jul 14 15:32 .npmignore
-rw-r--r--     1 jmiller  staff    3220 Jul 14 15:32 CODE_OF_CONDUCT.md
-rw-r--r--     1 jmiller  staff    2509 Jul 14 15:32 CONTRIBUTING.md
-rw-r--r--     1 jmiller  staff   11357 Jul 14 15:32 LICENSE
-rw-r--r--     1 jmiller  staff    3420 Jul 14 15:32 README.md
-rw-r--r--     1 jmiller  staff   11063 Jul 14 15:32 THIRD_PARTY_NOTICES.md
-rw-r--r--     1 jmiller  staff    5798 Jul 14 15:32 cla.md
drwxr-xr-x     3 jmiller  staff      96 Jul 15 10:30 node_modules
-rw-r--r--     1 jmiller  staff  138885 Jul 14 15:32 package-lock.json
-rw-r--r--     1 jmiller  staff    1292 Jul 14 15:32 package.json
drwxr-xr-x     6 jmiller  staff     192 Jul 15 10:30 src
-rw-r--r--     1 jmiller  staff    4446 Jul 14 15:32 third_party_manifest.json

When looking at this repo, it looks like there is no index.js file in the root, so yarn follows more closely with the structure defined in the repo.

Steps to Reproduce

Install this package via yarn.

Expected Behaviour

I can run this plugin with no problems regardless of whether I install via npm or yarn

jerelmiller commented 4 years ago

It appears this may be due to the fact that yarn currently doesn't not run the prepare script when installing from a local source: https://github.com/yarnpkg/yarn/issues/5235

Are we willing to publish this package to the npm registry? I think simply publishing this package would fix the issue.

jerelmiller commented 4 years ago

Looks like this was fixed as a result of publishing the package. Thanks for the help!